# Dot Pattern

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

- Kind: Motion component (Layout)
- Docs: https://ui.minidev.pro/docs/dot-pattern
- Source (registry JSON with the full file): https://ui.minidev.pro/r/dot-pattern.json
- License: MIT. One file, yours to edit after install.

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

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/dot-pattern
```

Writes `components/ui/dot-pattern.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/dot-pattern.json`.

### npm package

```bash
npm i minidev-ui-kit motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

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

From the npm package:

```tsx
import { DotPattern } from "minidev-ui-kit/premium/dot-pattern"
```

## Usage

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

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

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `variant` | `"dots" \| "grid"` | `"dots"` | no | Dots at each cell centre, or hairline grid lines. |
| `gap` | `number` | `18` | no | Cell size in pixels. |
| `weight` | `number` | `1` | no | Dot radius or line width. |
| `glow` | `boolean` | `true` | no | Light the pattern under the pointer. |
| `fade` | `boolean` | `true` | no | Fade the edges with a radial mask. |
| `className` | `string` | - | no |  |
| `children` | `React.ReactNode` | - | no |  |

## Examples

### Grid variant

variant grid draws hairlines instead of dots; gap is the cell size in pixels.

```tsx
<DotPattern variant="grid" gap={32} className="h-64" />
```

### Custom content

Children replace the sample copy and sit above the pattern; the glow still follows the pointer behind them.

```tsx
<DotPattern className="h-72">
  <div className="flex h-full flex-col items-center justify-center gap-4 px-6 text-center">
    <span className="rounded-full border border-border bg-surface px-2.5 py-0.5 text-xs font-medium text-fg-muted shadow-xs">Lumen for agencies</span>
    <p className="max-w-[20ch] text-3xl font-medium tracking-[-0.035em] text-balance text-fg">Bill every client from one place</p>
    <Button>Start free <ArrowRightIcon /></Button>
  </div>
</DotPattern>
```

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

```tsx
<DotPattern gap={10} weight={0.75} glow={false} fade={false} className="h-48">
  <div className="flex h-full flex-col items-center justify-center gap-3 px-6">
    <p className="text-xs font-medium tracking-[0.06em] text-fg-subtle uppercase">Trusted by finance teams at</p>
    <div className="flex flex-wrap items-center justify-center gap-x-8 gap-y-2 text-sm font-medium text-fg-muted">
      <span>Northwind</span>
      <span>Okafor and Sons</span>
      <span>Raman Studio</span>
      <span>Lowe Logistics</span>
    </div>
  </div>
</DotPattern>
```

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

## FAQ

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

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `motion`

## Related

- [Flickering Grid](https://ui.minidev.pro/docs/flickering-grid/md): React canvas background of small squares whose opacity flickers at random, with square size, gap, flicker chance, color and radial fade mask props.
- [Background Boxes](https://ui.minidev.pro/docs/background-boxes/md): React background of skewed hairline boxes: the box under the pointer lights up in colour and fades out, driven by one pointer handler and CSS transitions.
- [Particles](https://ui.minidev.pro/docs/particles/md): React canvas background of drifting particles that repel or attract around the pointer, colored from your accent token and sharp on high density screens.
- [Retro Grid](https://ui.minidev.pro/docs/retro-grid/md): React retro grid background: a perspective floor receding to a glowing horizon that scrolls slowly toward the viewer, with angle and cell size props.
- [Accordion](https://ui.minidev.pro/docs/accordion/md): Accessible React accordion on Base UI, with bordered items, a rotating chevron and animated panels. Keyboard navigable, with one or many items open at once.
- [App Shell](https://ui.minidev.pro/docs/app-shell/md): Tailwind app shell layout with a fixed width sidebar slot, a topbar slot and a scrolling main area. The sidebar hides below the md breakpoint for mobile.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
