Grid pattern
A background of lines, dots or crosses that fills its parent, for a hero, an empty state or a card that needs texture. It is an SVG pattern in the border colour, so it stays quiet in both themes. It never moves; for light that travels a border, use the border beam.
Install
npx shadcn@latest add @thrum-pro/grid-patternThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "grid" | "dots" | "crosses" | Default "grid" | Lines along every cell edge, a dot at every crossing, or a small cross at every crossing. |
size | number | Default 24 | The side of one cell, in pixels. Anything under 4 is drawn as 4. |
strokeWidth | number | Default 1 | The width of the lines and crosses, in pixels. |
dotRadius | number | Default 1 | The radius of each dot, in pixels. |
fade | "none" | "radial" | "linear" | Default "none" | Fade the pattern out towards the edges (radial) or towards the bottom (linear), through a CSS mask. |
highlight | readonly [x: number, y: number][] | Default [] | Cells to fill with a light tint, by column and row. The top left cell is [0, 0]. |
interactive | boolean | Default false | Illuminate the cell under the pointer when hovering the parent container. Disabled on touch and under reduced motion. |
className | string | – | Extra classes, merged last. A text colour class recolours the pattern. |
...props | ComponentProps<"svg"> | – | Every other SVG attribute is passed through. The pattern takes no children. |
Motion and sound
Motion
- At rest the pattern does not move.
- With interactive enabled, the cell beneath the pointer fades in with a primary tint over 150 ms. Disabled on touch devices and under reduced motion.
Sound
Silent. This component makes no sound.
Accessibility
- The pattern is decoration. It is hidden from screen readers with aria-hidden and takes no pointer events, so text and controls on top of it work as usual.
- Its marks use the theme's border colour and highlighted cells use the foreground at 8% (shifting to 20% marks with a 14% primary tint under glass materials). Both stay well under the contrast of any text drawn over them.
- The pattern fills its nearest positioned parent. Give the parent relative and overflow-hidden, and put the content after the pattern in a positioned element so it is drawn on top.
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/grid-pattern.tsx- Packages
- None
- Brings along
- Nothing
Changelog
- 1.0.0 · 2026-12-03First release.