Dot Pattern
MotionA dot or grid background drawn as one SVG pattern, faded at the edges, with an optional accent glow that follows the pointer and lights the dots beneath it.
Installation
npx shadcn@latest add @minidev/dot-pattern
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/dot-pattern.json
Usage
import { DotPattern } from "@/components/ui/dot-pattern"
export function Example() {
return (
<DotPattern />
)
}
API reference
| Prop | Type | Default |
|---|---|---|
| variantDots at each cell centre, or hairline grid lines. | "dots""grid" | "dots" |
| gapCell size in pixels. | number | 18 |
| weightDot radius or line width. | number | 1 |
| glowLight the pattern under the pointer. | boolean | true |
| fadeFade the edges with a radial mask. | boolean | true |
| className | string | - |
| children | React.ReactNode | - |
When to use
The pattern sits behind your children with pointer-events off. The glow writes CSS variables on pointer move, so React never re-renders while it follows; it is off for reduced motion. Use it as a quiet section or hero backdrop; for animated texture use FlickeringGrid, for a reactive grid of boxes use BackgroundBoxes.
Accessibility
- Both SVG layers are
aria-hiddenandpointer-events-none, so links and buttons inchildrenstay clickable and screen readers skip the texture. - Under
prefers-reduced-motion: reducethe glow layer is not rendered and pointer moves are ignored; the static pattern stays.
Frequently asked questions
Does the pointer glow hurt performance?
No React re-render happens while the pointer moves: the handler writes --dp-x, --dp-y and --dp-on on the element and CSS moves a radial mask. The pattern itself is a single SVG <pattern> fill. Pass glow={false} to drop the second layer.
How do I use it as a full-width hero background?
It defaults to a 320px framed box. Pass className="h-auto min-h-[480px] rounded-none border-0" and your hero as children. Your children are not centred for you; add grid place-items-center to the wrapper you pass in.
How do I change the dot colour?
Dots use --border-strong, grid lines use --border and the glow uses --accent. Redefine those variables on a parent element to retint one section without touching the component.
Dependencies
npm
Built from
Examples
Grid variant
variant grid draws hairlines instead of dots; gap is the cell size in pixels.
Custom content
Children replace the sample copy and sit above the pattern; the glow still follows the pointer behind them.
Dense, still texture
A small gap and a light weight make a fine texture; glow false and fade false leave it flat and even behind a quiet row.