In view
A block that animates in as it scrolls into view, and again each time it comes back.
Scroll this panel.
Block 1
Block 2
Block 3
Block 4
Keep scrolling.
Installation
pnpm add @heyramzi/uiUsage
import { InView, onInView } from "@heyramzi/ui/effects/reveal";<InView preset="slide" amount={0.4}>
{#snippet children()}
<span>Block 1</span>
{/snippet}
</InView>
<p use:onInView={{ amount: 0.6, onEnter: () => (seen = true) }}>Keep scrolling.</p>Keyboard and accessibility
- With reduced motion on, the content shows at once with no fade or blur.
API reference
childrenrequiredSnippet<[boolean]>asstring- Default
"div" - Tag to render. Default `div`.
classstringpreset"fade" | "slide" | "blur" | "blur-slide" | "scale" | "zoom"- Default
"fade" - Preset geometry. Default `fade`.
delaynumber- Wait before the first item starts, in ms.
staggernumber- Gap between consecutive items, in ms. Defaults to `--duration-stagger`.
durationnumber- One item's run time, in ms. Defaults to `--duration-slow`.
onceboolean- Default
true - Play once and stay revealed, instead of replaying on every re-entry.
amountnumber- Fraction of the element that must be visible before it plays.
marginstring- `rootMargin` for the observer, e.g. `"0px 0px -15% 0px"`.
| Prop | Type | Default |
|---|---|---|
children required | Snippet<[boolean]> | |
as Tag to render. Default `div`. | string | "div" |
class | string | |
preset Preset geometry. Default `fade`. | "fade" | "slide" | "blur" | "blur-slide" | "scale" | "zoom" | "fade" |
delay Wait before the first item starts, in ms. | number | |
stagger Gap between consecutive items, in ms. Defaults to `--duration-stagger`. | number | |
duration One item's run time, in ms. Defaults to `--duration-slow`. | number | |
once Play once and stay revealed, instead of replaying on every re-entry. | boolean | true |
amount Fraction of the element that must be visible before it plays. | number | |
margin `rootMargin` for the observer, e.g. `"0px 0px -15% 0px"`. | string |