Parallax
Moves its direct children with CSS scroll-driven animation while the root crosses the viewport, and stays static under reduced motion.
- Frameworks
- Astro · React · Elements · Dioxus
- Registry
lumen add Parallax- Interaction
- Native markup
See it and copy it
Framework example
Choose Astro, React, Elements, or Dioxus to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

The framed image drifts inside its clipped frame and this card moves past it while the section scrolls. Reduced motion keeps both still.
View Parallax code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.---
import { Card, Grid, Image, Parallax } from '@santi020k/lumen-astro'
---
<Grid style="align-items: start;">
<Parallax clip from={-8} to={8} zoom={1.2} style="border-radius: var(--ui-radius-lg);">
<Image alt="A still mountain lake at dusk with warm light on the peaks" height={960} radius="none" src="/demo-media/lake-dusk.webp" width={1440} />
</Parallax>
<Parallax from={10} to={-10}>
<Card>
<strong>Depth without JavaScript</strong>
<p>The framed image drifts inside its clipped frame and this card moves past it while the section scrolls. Reduced motion keeps both still.</p>
</Card>
</Parallax>
</Grid>import type { CSSProperties } from 'react'
import { Card, Grid, Image, Parallax } from '@santi020k/lumen-react'
const exampleStyle0: CSSProperties & Record<`--${string}`, string | number> = { "borderRadius": "var(--ui-radius-lg)" }
export const Example = () => (
<>
<Grid style={{ "alignItems": "start" }}>
<Parallax clip from={-8} to={8} zoom={1.2} style={exampleStyle0}>
<Image alt="A still mountain lake at dusk with warm light on the peaks" height={960} radius="none" src="/demo-media/lake-dusk.webp" width={1440} />
</Parallax>
<Parallax from={10} to={-10}>
<Card>
<strong>Depth without JavaScript</strong>
<p>The framed image drifts inside its clipped frame and this card moves past it while the section scrolls. Reduced motion keeps both still.</p>
</Card>
</Parallax>
</Grid>
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-grid style="align-items: start;">
<lumen-parallax clip from="-8" to="8" zoom="1.2" style="border-radius: var(--ui-radius-lg);">
<lumen-image radius="none">
<img alt="A still mountain lake at dusk with warm light on the peaks" src="/demo-media/lake-dusk.webp" width="1440" height="960" />
</lumen-image>
</lumen-parallax>
<lumen-parallax from="10" to="-10">
<lumen-card>
<strong>Depth without JavaScript</strong>
<p>The framed image drifts inside its clipped frame and this card moves past it while the section scrolls. Reduced motion keeps both still.</p>
</lumen-card>
</lumen-parallax>
</lumen-grid>use dioxus::prelude::*;
use lumen_dioxus::prelude::*;
#[component]
fn Example() -> Element {
rsx! {
Parallax { clip: true, zoom: 1.2, style: "height: 200px;",
img { alt: "Mountains at dawn", src: "/mountains.jpg" }
}
}
}Framework differences
React: The React root is a div; the Astro as prop is not part of the React API. Pass from, to, and zoom as numbers. A style prop is merged with the generated --ui-parallax-* properties.
Elements: lumen-parallax is the root, so its direct children move. Set from, to, and zoom as numeric attributes and clip as a boolean attribute. For a framed photo, compose a native img inside lumen-image.
Choose your target
Add this component
Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.
pnpm add @santi020k/lumen-astrolumen add Parallaxpnpm add @santi020k/lumen-reactlumen add Parallax --target reactpnpm add @santi020k/lumen-elementslumen add Parallax --target elementsAPI reference
Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.
| Attribute | Values | Default | Description |
|---|---|---|---|
| as | "div" | "figure" | "section" | "div" | Sets the semantic root. The React root is a div and the Elements root is the element itself. |
| from | number (% of each child's height) | -6 | Starting vertical offset of every direct child as the root enters the viewport, clamped to -50–50. Non-finite values use the default. |
| to | number (% of each child's height) | 6 | Ending vertical offset as the root leaves the viewport, clamped to -50–50. A column that drifts up past copy uses from={0} to={-20}. Keep unclipped drift modest: a moving child paints above its neighbors and can cover their links. |
| zoom | number | 1 | Constant scale of every direct child, clamped to 1–1.5, so a clipped image keeps covering its frame while it moves. Cover the travel with at least 1 + 2 × the largest offset (for example zoom={1.08} for ±3), so clipped offsets beyond ±25 cannot stay covered. Without clip, zoom can widen the page; pair it with clip. |
| clip | boolean | false | Clips the moving children to the root's box for framed images. Elements use the boolean clip attribute. |
| children | block or replaced direct children | required | Every direct child moves with the individual translate and scale properties, so the observed root never moves. Inline boxes and display: contents wrappers do not move, so use block content or media such as img and svg, and give a picture display: block. A figcaption or a nested Parallax root stays put. Lumen owns translate, scale and animation on direct children; wrap a child that already sets them or runs its own animation, such as a ScrollReveal. Parallax follows its nearest scroll container, so an overflow: hidden ancestor stops it. |
| scroll-driven animation / reduced motion | view-timeline on the root, range cover | - | Pure CSS with no runtime. Children stay in place where scroll-driven animations are unsupported, under the system reduced-motion preference, and inside a data-ui-motion="reduce" ancestor. Content order, reading order and focus never change. |
| CSS variables | --ui-parallax-from / --ui-parallax-to / --ui-parallax-zoom | set from props | Written on the root from the clamped props. Prefer the props; .ui-parallax and .ui-parallax--clip are the documented class hooks. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML attributes | - | Forwards standard attributes to the root element unless the component consumes them. |
Customize Parallax
Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.
.product-parallax {
--surface: 0 0% 100%;
--ink: 220 20% 15%;
--line: 220 15% 82%;
}Apply product-parallax through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.
Documented styling parts: parallax parallax--clip
| Hook | Values | Default | Contract |
|---|---|---|---|
| CSS variables | --ui-parallax-from / --ui-parallax-to / --ui-parallax-zoom | set from props | Written on the root from the clamped props. Prefer the props; .ui-parallax and .ui-parallax--clip are the documented class hooks. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope