ParallaxSection
Render a full-viewport section with a background image that moves vertically as the section scrolls through the viewport.
ParallaxSection is a client component that renders a 100vh section with a darkened next/image background that shifts from -20% to 20% as the section scrolls past. Use it for full-height marketing sections with a heading over an image. It depends on motion/react and next/image. Scroll the page to see the background move; the demos clip the section to a fixed height.
Built for every season
Import#
import { ParallaxSection } from "@reactberry/system/blocks";
Usage#
import { ParallaxSection } from "@reactberry/system/blocks";
import { Box, Text } from "@reactberry/system/elements";
export default function Overview() {
return (
<ParallaxSection
image="/images/overview.jpg"
content={
<Box
position="relative"
zIndex={1}
height="100%"
display="flex"
alignItems="center"
justifyContent="center"
>
<Text as="h2" fontSize="xxxl" fontWeight="700" color="white">
Built for every season
</Text>
</Box>
}
/>
);
}
Examples#
Call to action#
content can hold any layout, such as a heading, a short line of copy and a link.
API#
ParallaxSection#
| Prop | Type | Default | Description |
|---|---|---|---|
image* | string | — | Background image source passed to |
content | ReactNode | — | Rendered inside the section, before the background layer. Give it a positioned wrapper with |
No other props are accepted or spread. children is not supported; use content.
Accessibility#
- The root element is a
sectionwithout an accessible name; include a heading incontent. - The image has a fixed
alt="Overview", which can't be changed or cleared for decorative images. - There is no reduced-motion handling.
Notes#
- The background layer is absolutely positioned with
zIndex0. Givecontenta positioned wrapper (for exampleposition="relative"withzIndex1) so it renders above the image. - The background layer is 120% of the section height and its
topis driven byuseScrollwith offset["start end", "end start"]. - A fixed
rgba(0, 0, 0, 0.3)overlay is drawn above the image. There is no prop to change it. - The image uses
fill,sizes="100vh"andobjectFit: "cover". - The section height is fixed at
100vhwithoverflow: hidden. - Remote image URLs must be allowed in your Next.js
imagesconfiguration.