Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Dot Pattern

FreeNew

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

dot-pattern-demo.tsx
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

PropTypeDefault
spacingnumber

Distance between dot centers in CSS pixels.

16
radiusnumber

Dot radius in CSS pixels.

1
classNamestring

Use text color utilities to tint the dots.

—
styleCSSProperties—

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.