# Dot Grid

> A transparent grid of dots for section backgrounds, with an optional slow wave, twinkle, edge fade, and pointer highlight.

Source: https://www.honestui.com/docs/shaders/dot-grid

<ComponentPreview name="dot-grid-demo" />

## Overview [#overview]

Dot Grid draws an evenly spaced lattice of dots on a transparent canvas, so it sits on any surface. It is the quiet background behind a hero, an empty state, or a feature section. The dots default to `currentColor` at low opacity, so they follow your text color and switch with the theme.

Optional layers add life without noise:

* **Wave** swells and shrinks the dots in a slow diagonal pattern.
* **Twinkle** fades individual dots in and out.
* **Pointer highlight** grows and recolors the dots near the cursor.
* **Fade** dissolves the grid toward the edges, the top, or the bottom so it never ends in a hard line.

The grid is centered, so the outer dots sit the same distance from each edge, and it stays crisp at any device pixel ratio.

## Installation [#installation]

<CommandBlock commands="[&#x22;honestui&#x22;]" />

## Usage [#usage]

```tsx
import { DotGrid } from "honestui/shaders"

<section className="relative overflow-hidden rounded-xl border">
  <DotGrid className="absolute inset-0" fade="radial" wave={0.3} />
  <div className="relative p-12">
    <h2>Ship it calmly.</h2>
  </div>
</section>
```

Pass content as children or layer it above the grid as in the example. Any CSS color works for `color` and `highlightColor`, including custom properties such as `var(--primary)`.

A static grid with no wave, twinkle, or pointer highlight renders once and only redraws on resize, so it costs almost nothing.

## Accessibility [#accessibility]

The canvas is hidden from assistive technology and the grid is decoration only. Keep dot opacity low behind text and check contrast where the highlight passes under content. The wave and twinkle stop when the user prefers reduced motion, while the element is offscreen, and while the page is hidden. The pointer highlight follows the cursor only and carries no information.

## API Reference [#api-reference]


  ### `gap`

type: `number` · default: `20`

Distance between dot centers in CSS pixels.

  ### `dotSize`

type: `number` · default: `2`

Dot diameter in CSS pixels.

  ### `shape`

type: `&#x22;circle&#x22; | &#x22;square&#x22; | &#x22;diamond&#x22; | &#x22;cross&#x22;` · default: `&#x22;circle&#x22;`

Dot shape.

  ### `color`

type: `string` · default: `&#x22;currentColor&#x22;`

Dot color. Any CSS color.

  ### `opacity`

type: `number` · default: `0.35`

Dot opacity from 0 to 1.

  ### `wave`

type: `number` · default: `0`

Strength of the slow wave from 0 to 1.

  ### `twinkle`

type: `number` · default: `0`

Strength of the per-dot twinkle from 0 to 1.

  ### `speed`

type: `number` · default: `1`

Animation speed.

  ### `interactive`

type: `boolean` · default: `true`

Grows and brightens dots near the pointer.

  ### `highlightColor`

type: `string`

Color of dots near the pointer. Defaults to 

    `color`

    .

  ### `highlightRadius`

type: `number` · default: `140`

Radius of the pointer highlight in CSS pixels.

  ### `highlightScale`

type: `number` · default: `2.2`

Dot scale at the center of the highlight.

  ### `fade`

type: `&#x22;none&#x22; | &#x22;radial&#x22; | &#x22;edges&#x22; | &#x22;top&#x22; | &#x22;bottom&#x22;` · default: `&#x22;none&#x22;`

Fades the grid out toward the edges.

  ### `paused`

type: `boolean` · default: `false`

Renders one still frame.

  ### `className`

type: `string`

Class for sizing and positioning the container.

  ### `children`

type: `ReactNode`

Content layered above the grid.
