Skip to content

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/illustrations

import { DotGrid, LineGrid, IsoGrid } from '@youj/illustrations'

For 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, gap px apart, of radius size.
  • LineGrid: hairlines gap px apart, a stronger line every major cells, 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 every gap px, 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.

Reference

Propssize, gap, fade… (19)

Props

DotGrid

DotGrid props
PropType
sizenumber

Dot radius, CSS px.

default 1

1
gapnumber

Distance between grid points or lines, CSS px.

default 16

16
fadeGridFade
'none''edges''radial'

Fade out toward the edges ('edges'), from the center ('radial'), or not at all.

default 'radial'

'radial'
classNamestring–
styleCSSProperties–

LineGrid

LineGrid props
PropType
majornumber

A stronger line every this many cells, with a registration cross where two meet; 0 for none.

default 4

4
gapnumber

Distance between grid points or lines, CSS px.

default 24

24
fadeGridFade
'none''edges''radial'

Fade out toward the edges ('edges'), from the center ('radial'), or not at all.

default 'radial'

'radial'
classNamestring–
styleCSSProperties–

IsoGrid

IsoGrid props
PropType
gapnumber

Distance between grid points or lines, CSS px.

default 24

24
fadeGridFade
'none''edges''radial'

Fade out toward the edges ('edges'), from the center ('radial'), or not at all.

default 'radial'

'radial'
classNamestring–
styleCSSProperties–
Other props pass through: extends SVGProps<SVGSVGElement>.

IsoFloor

IsoFloorProps props
PropType
wRequirednumber

The floor's extent in grid units, from the origin.

–
dRequirednumber–
stepnumber

Grid spacing in grid units.

default 1

1
kind'lines' | 'dots'

Draw lines, or dots at the crossings.

default 'lines'

'lines'
classNamestring–
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-hidden and 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.