Components
Parallax
A layer that scrolls at a different speed, creating depth.
Overview
<Parallax> moves its children at a different scroll speed than the page, creating a sense of depth. Use speed < 1 for background layers and speed > 1 for foreground layers.
Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
speed | number | 0.5 | Speed multiplier. 1 = normal scroll, < 1 = slower (background feel), > 1 = faster (foreground feel) |
direction | "vertical" | "horizontal" | "vertical" | Scroll direction for the parallax offset |
children | ReactNode | -- | Content to apply parallax to |
className | string | -- | CSS class |
style | CSSProperties | -- | Inline styles (merged with transform) |
How it works
The parallax offset is calculated as:
The transform is applied using translateY (or translateX for horizontal) for GPU-accelerated performance.
Accessibility
When prefers-reduced-motion is enabled, the parallax offset is disabled and content scrolls normally.