Dot Pattern
FreeNewA precise dot grid with adjustable spacing and radius, drawn with one CSS gradient.
Installation
pnpm dlx shadcn@latest add @viewport/dot-pattern
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above.
import { DotPattern } from "@/components/viewport/dot-pattern";
export default function DotPatternDemo() {
return (
<div className="relative flex min-h-64 w-full items-end overflow-hidden rounded-xl border border-border bg-background p-5 sm:p-7">
<DotPattern className="text-foreground/25" />
<div className="relative max-w-full rounded-lg border border-border bg-card px-4 py-3">
<p className="text-xs text-muted-foreground">Workspace</p>
<h2 className="mt-1 text-lg font-semibold tracking-tight">Project overview</h2>
</div>
</div>
);
}Props
| Prop | Type | Default |
|---|---|---|
| spacing | numberDistance between dot centers in CSS pixels. | 16 |
| radius | numberDot radius in CSS pixels. | 1 |
| className | stringUse text color utilities to tint the dots. | — |
| style | CSSProperties | — |
Accessibility
- Decorative and hidden from assistive technology.
- Ignores pointer events and is hidden in forced-colors mode.
- Static and requires no browser JavaScript to paint.