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.
This one has no events: it shows what it's given.
Source: reveal-on-scroll.zb, and its registry item.
Install
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
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
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
<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
<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>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>
);
}<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('-') } } }) --><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>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
| Property | Type | Default |
|---|---|---|
effect | "fade" | "fade-up" | "fade-down" | "blur" | "scale" | "slide-left" | "slide-right" | "fade-up" |
stagger | number | 0 |
threshold | number | 0.2 |
again | boolean | false |
| Slot | For |
|---|---|
(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.