Underlay
Render a backdrop-blurred surface with a dotted grid or gradient fill and an optional fade-out mask.
Underlay renders a Box with backdrop-filter: blur(), a background pattern, and an optional linear-gradient mask. It is typically placed behind sticky headers or toolbars so content scrolling underneath is blurred. It has no intrinsic size or position. Scroll the list in the demo to see the effect.
Today
Import#
import { Underlay } from "@reactberry/system/blocks";
Usage#
import { Underlay } from "@reactberry/system/blocks";
import { Box, Text } from "@reactberry/system/elements";
export default function StickyHeader() {
return (
<Box position="sticky" top="0" zIndex={10}>
<Underlay position="absolute" top="0" left="0" right="0" height="6rem" color="base" dotColor="transparent" />
<Box position="relative" p="m">
<Text as="h1" fontSize="l">Dashboard</Text>
</Box>
</Box>
);
}
Examples#
Gradient fill#
Set both stop1 and stop2 to replace the dot pattern with a gradient. hasMask={false} turns off the fade-out mask.
Dot grid#
dotColor, backgroundColor, dotSize and gridSize shape the dot pattern; blurAmount sets the blur radius.
API#
Underlay#
| Prop | Type | Default | Description |
|---|---|---|---|
backgroundColor | string | — | Colour between the dots. Falls back to |
dotColor | string | — | Colour of the dots. Falls back to |
dotSize | number | 1 | Pixel position where the dot fades to |
gridSize | number | 4 | Size in pixels of each repeating tile of the dot pattern. |
blurAmount | number | 12 | Backdrop blur radius in pixels. |
maskGradient | string | — | Contents of the mask's |
hasMask | boolean | true | Applies a CSS |
stop1 | string | — | First colour of a gradient fill. Needs |
stop2 | string | — | Second colour of a gradient fill. With |
All remaining props are spread onto the root Box after its defaults (bg="transparent", backgroundImage, backgroundSize), so they can override them.
Accessibility#
- The element is purely decorative and sets no ARIA attributes. Add
aria-hiddenthrough the spread props if needed.
Notes#
- With the defaults (
dotColorunset), the pattern is a radial gradient from transparent tocurrentColor, so the inherited orcolorprop value sets the visible fill. - With a gradient fill,
gridSizeis ignored. - After mount, and whenever
blurAmount,width,height, orexpandedchange, an effect clears and re-applies the inlinebackdropFilterto force the browser to repaint the blur.expandedis not declared in the props type but is read from the spread props and forwarded to theBox. - No animation is involved, so there is no reduced-motion handling.
UnderlayPropsis not exported.