Zubra UI
Code for
GitHub

reveal-on-scroll

Content that animates into place the first time it scrolls into view: fade, rise, blur, scale or slide (effect), each child after the last with stagger. Without JavaScript, or for visitors who asked for less motion, it's simply there; again replays it each time.

1.2kLoaves this month
38Classes taught
4.9Average rating

This one has no events: it shows what it's given.

Source: reveal-on-scroll.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/reveal-on-scroll.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/reveal-on-scroll.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/reveal-on-scroll.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/reveal-on-scroll.json
One file, no dependencies (3.7 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/reveal-on-scroll.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/reveal-on-scroll.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/reveal-on-scroll.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/reveal-on-scroll.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/reveal-on-scroll.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/reveal-on-scroll.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/reveal-on-scroll.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/reveal-on-scroll.json
No build: a script tag, straight from this site
HTML
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/reveal-on-scroll.js"></script>

The compiled install writes src/components/zubra/reveal-on-scroll.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.

Usage

index.html
<reveal-on-scroll effect="fade-up">
  <div class="demo-stats">
    <div class="demo-box"><strong>1.2k</strong>Loaves this month</div>
    <div class="demo-box"><strong>38</strong>Classes taught</div>
    <div class="demo-box"><strong>4.9</strong>Average rating</div>
  </div>
</reveal-on-scroll>

<script type="module">
  import './components/zubra/reveal-on-scroll.js';

  const element = document.querySelector('reveal-on-scroll');
  element.stagger = 90;
</script>
Example.jsx
import './components/zubra/reveal-on-scroll.js';

const stagger = 90;

export function RevealOnScrollExample() {
  return (
    <reveal-on-scroll effect="fade-up" stagger={stagger}>
      <div className="demo-stats">
        <div className="demo-box"><strong>1.2k</strong>Loaves this month</div>
        <div className="demo-box"><strong>38</strong>Classes taught</div>
        <div className="demo-box"><strong>4.9</strong>Average rating</div>
      </div>
    </reveal-on-scroll>
  );
}
Example.vue
<script setup>
import './components/zubra/reveal-on-scroll.js';
const stagger = 90;
</script>

<template>
  <reveal-on-scroll effect="fade-up" :stagger.prop="stagger">
    <div class="demo-stats">
      <div class="demo-box"><strong>1.2k</strong>Loaves this month</div>
      <div class="demo-box"><strong>38</strong>Classes taught</div>
      <div class="demo-box"><strong>4.9</strong>Average rating</div>
    </div>
  </reveal-on-scroll>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/reveal-on-scroll.js';
  const stagger = 90;
</script>

<reveal-on-scroll effect="fade-up" {stagger}>
  <div class="demo-stats">
    <div class="demo-box"><strong>1.2k</strong>Loaves this month</div>
    <div class="demo-box"><strong>38</strong>Classes taught</div>
    <div class="demo-box"><strong>4.9</strong>Average rating</div>
  </div>
</reveal-on-scroll>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/reveal-on-scroll.js';

@Component({
  selector: 'app-reveal-on-scroll-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <reveal-on-scroll effect="fade-up" [stagger]="stagger">
      <div class="demo-stats">
        <div class="demo-box"><strong>1.2k</strong>Loaves this month</div>
        <div class="demo-box"><strong>38</strong>Classes taught</div>
        <div class="demo-box"><strong>4.9</strong>Average rating</div>
      </div>
    </reveal-on-scroll>
  `,
})
export class RevealOnScrollExample {
  stagger = 90;
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
effect"fade" | "fade-up" | "fade-down" | "blur" | "scale" | "slide-left" | "slide-right""fade-up"
staggernumber0
thresholdnumber0.2
againbooleanfalse
Slots
SlotFor
(default)The content to reveal.

Size

1.1 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.6 KB.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour