Skip to documentation content

In View

Reveal content as it scrolls into view, as one block or one child at a time.

in-view-demo

Overview

In View plays an entrance when its element scrolls into the viewport. Choose a preset (fade, slide-up, slide-down, blur, or scale) or pass your own variants. With stagger, each direct child is wrapped and enters in turn, which suits lists, feature grids, and timelines.

By default the entrance plays once. Set once={false} to replay it whenever the element leaves and comes back. amount controls how much of the element must be visible before it starts, and margin grows or shrinks the viewport, so an entrance can begin a little before the element reaches the screen.

Installation

npx honestui@latest add in-view

Usage

import { InView } from "@/components/animated/in-view"

<InView preset="blur">
  <h2>Built for teams</h2>
</InView>

<InView as="ul" preset="slide-up" stagger={0.08}>
  {features.map((feature) => (
    <FeatureCard key={feature.id} {...feature} />
  ))}
</InView>

When as is ul or ol, staggered children are wrapped in li elements, so pass the item content rather than your own li.

Accessibility

Content is hidden only visually until it enters, so it stays in the page for screen readers and search. Under reduced motion the entrance keeps a short fade and drops movement, blur, and scale.

Keep entrances short and avoid them on content people need immediately, such as the first screen of a page or an error message. Content revealed on scroll should never be the only place an important instruction appears.

API Reference

PropTypeDefaultDescription
children*ReactNode–Content to reveal.
asdiv|section|article|header|footer|ul|ol|li|span|p"div"Element to render.
presetfade|slide-up|slide-down|blur|scale"blur"Entrance style.
variantsVariants–Custom motion variants with hidden and visible keys. Overrides preset.
staggernumber0Seconds between each direct child's entrance. 0 animates the wrapper as one block.
delaynumber0Seconds before the entrance starts.
durationnumber0.6Entrance duration in seconds.
oncebooleantruePlay only the first time the element enters.
amount"some" | "all" | number0.25How much of the element must be visible.
marginstring–Root margin, such as "0px 0px -10% 0px".
classNamestring–Classes for the wrapper.
itemClassNamestring–Classes for each wrapped child when stagger is set.