Skip to content

Dot Pattern

Motion

A 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.

src/registry/premium/dot-pattern.tsx/r/dot-pattern.json

Installation

bash
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

tsx
import { DotPattern } from "@/components/ui/dot-pattern"

export function Example() {
  return (
    <DotPattern />
  )
}

API reference

DotPattern props
PropTypeDefault
variantDots at each cell centre, or hairline grid lines."dots""grid""dots"
gapCell size in pixels.number18
weightDot radius or line width.number1
glowLight the pattern under the pointer.booleantrue
fadeFade the edges with a radial mask.booleantrue
classNamestring-
childrenReact.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-hidden and pointer-events-none, so links and buttons in children stay clickable and screen readers skip the texture.
  • Under prefers-reduced-motion: reduce the 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

motion

Built from

No other MiniDev files

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.

All layout components