Stagger

Brings the children of a list or a grid in one after the other.

Dependenciesmotion
L
Lina MoreauDesign
M
Marc DuboisEngineering
S
Sofia RossiProduct
N
Noah WeberSupport

Installation#

pnpm dlx shadcn@latest add @balick/stagger

Or pass the full URL: https://ui.balick.me/r/stagger.json

Usage#

import { Stagger } from "@/components/ui/stagger"

export function Team({ people }: { people: string[] }) {
  return (
    <Stagger className="grid gap-3 sm:grid-cols-2" interval={0.1} inView>
      {people.map((person) => (
        <div key={person} className="rounded-lg border p-4">
          {person}
        </div>
      ))}
    </Stagger>
  )
}

Props#

PropTypeDefault
interval

Delay between two children, in seconds.

number0.08
delay

Delay before the first child, in seconds.

number0
duration

Duration of each child's entrance, in seconds.

number0.45
offset

Distance travelled by each child, in pixels.

number12
direction

Direction the children come from.

"up" | "down" | "left" | "right""up"
inView

Wait until the group scrolls into view before animating.

booleanfalse
inViewMargin

Margin applied to the viewport when inView is set.

string"-50px"
itemClassName

Class name of the wrapper around each child. Every direct child is wrapped in a div.

string—