Grid Backdrops
Add dot, line or isometric grids behind your content using theme colors.
A grid tells the reader they're looking at a drawing: something measured, with parts in their places. Put one behind an isometric scene, a hero figure, or an empty state's illustration. Use one grid per surface, and keep it faint: it's paper, not content.
Installation
npm i @youj/illustrationsFor an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.
Usage
Each backdrop fills its nearest positioned ancestor and paints behind the content, like the background components, so give the container relative isolate.
import { IsoScene, IsoStack, LineGrid } from '@youj/illustrations'
export function Figure() {
return (
<figure className="relative isolate rounded-xl border border-line bg-surface p-8">
<LineGrid gap={20} />
<IsoScene explode>…</IsoScene>
</figure>
)
}DotGrid: dots on a square grid,gappx apart, of radiussize.LineGrid: hairlinesgappx apart, a stronger line everymajorcells, and a small registration cross where two strong lines meet.major={0}leaves only the fine lines.IsoGrid: the isometric rhombi of a scene's floor, one grid unit everygappx, for a backdrop that shares the drawing's angles.
Examples
Fading
fade sets how a backdrop meets the edge of its container. radial (the default) fades out from the middle, so the paper is densest behind the figure. edges fades a band along each side and keeps the middle even, for a wide panel. none runs it to the edge, for a container that clips it with its own border.
A scene's floor
IsoFloor goes inside an IsoScene: the scene's own grid on the floor, in its units, from the origin to w by d, every step units. Shapes placed on whole numbers stand on its lines. Draw it first, so it stays under the shapes, as lines or, with kind="dots", as dots at the crossings.
Color
The lines and dots are the ink at a low strength over transparent, so they read on a surface, a raised panel or the canvas, in either scheme and every preset, and a theme change repaints them with no JavaScript.
Reference
Propssize, gap, fade… (19)
Props
DotGrid
| Prop | Type | |
|---|---|---|
size | numberDot radius, CSS px. default 1 | 1 |
gap | numberDistance between grid points or lines, CSS px. default 16 | 16 |
fade | GridFade'none''edges''radial'Fade out toward the edges ('edges'), from the center ('radial'), or not at all. default 'radial' | 'radial' |
className | string | – |
style | CSSProperties | – |
LineGrid
| Prop | Type | |
|---|---|---|
major | numberA stronger line every this many cells, with a registration cross where two meet; 0 for none. default 4 | 4 |
gap | numberDistance between grid points or lines, CSS px. default 24 | 24 |
fade | GridFade'none''edges''radial'Fade out toward the edges ('edges'), from the center ('radial'), or not at all. default 'radial' | 'radial' |
className | string | – |
style | CSSProperties | – |
IsoGrid
| Prop | Type | |
|---|---|---|
gap | numberDistance between grid points or lines, CSS px. default 24 | 24 |
fade | GridFade'none''edges''radial'Fade out toward the edges ('edges'), from the center ('radial'), or not at all. default 'radial' | 'radial' |
className | string | – |
style | CSSProperties | – |
Other props pass through: extends SVGProps<SVGSVGElement>. | ||
IsoFloor
| Prop | Type | |
|---|---|---|
wRequired | numberThe floor's extent in grid units, from the origin. | – |
dRequired | number | – |
step | numberGrid spacing in grid units. default 1 | 1 |
kind | 'lines' | 'dots'Draw lines, or dots at the crossings. default 'lines' | 'lines' |
className | string | – |
Reduced motionNothing here moves, so there's nothing to stop
Reduced motion
Nothing here moves, so there's nothing to stop: a backdrop looks the same with reduced motion on.
AccessibilityARIA
Accessibility
- Backdrops are decorative: each is
aria-hiddenand ignores pointer events. - They sit at a low strength, but check the contrast of any text you set over the densest part of a grid.