Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

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/ui

Usage

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

children required Snippet<[boolean]>
as string
Default "div"
Tag to render. Default `div`.
class string
preset "fade" | "slide" | "blur" | "blur-slide" | "scale" | "zoom"
Default "fade"
Preset geometry. Default `fade`.
delay number
Wait before the first item starts, in ms.
stagger number
Gap between consecutive items, in ms. Defaults to `--duration-stagger`.
duration number
One item's run time, in ms. Defaults to `--duration-slow`.
once boolean
Default true
Play once and stay revealed, instead of replaying on every re-entry.
amount number
Fraction of the element that must be visible before it plays.
margin string
`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