Dot Background
A decorative dot pattern background with customizable spacing, dot size, and opacity.
Default
Live-tune dot spacing, dot size, and opacity in the controls panel
New component preview
Build cleaner interfaces with reusable UI patterns.
A compact landing page test for checking layout flow, spacing, background layering, and child content inside the dot background component.
Layered correctly
The dot pattern sits behind the content while cards and text remain interactive and readable.
Works with sections
Multiple blocks can stack naturally without escaping the background wrapper.
Responsive spacing
The layout adapts from a single-column mobile view to a wider desktop grid.
dot-background-example.tsx
1import { ArrowRight, CheckCircle2, Sparkles } from "lucide-react";23import { Button } from "@/components/ui/button";4import { DotBackground } from "@/registry/ui/dot-background";56export function DotBackgroundDefaultExample() {7 return (8 <DotBackground className="min-h-screen bg-background">9 <main className="mx-auto flex min-h-screen w-full max-w-6xl flex-col px-6 py-16 sm:px-8 lg:px-10">10 {/* Hero */}11 <section className="flex flex-1 flex-col items-center justify-center text-center">12 <div className="mb-6 inline-flex items-center gap-2 rounded-full border bg-background/80 px-4 py-2 text-sm text-muted-foreground shadow-sm backdrop-blur">13 <Sparkles className="size-4" />14 New component preview15 </div>1617 <h1 className="max-w-4xl text-balance text-5xl font-bold tracking-tight sm:text-6xl lg:text-7xl">18 Build cleaner interfaces with reusable UI patterns.19 </h1>2021 <p className="mt-6 max-w-2xl text-pretty text-lg leading-8 text-muted-foreground">22 A compact landing page test for checking layout flow, spacing,23 background layering, and child content inside the dot background24 component.25 </p>2627 <div className="mt-8 flex flex-col gap-3 sm:flex-row">28 <Button size="lg" className="gap-2">29 Get started30 <ArrowRight className="size-4" />31 </Button>3233 <Button size="lg" variant="outline">34 View components35 </Button>36 </div>37 </section>3839 {/* Feature cards */}40 <section className="grid gap-4 py-20 sm:grid-cols-2 lg:grid-cols-3">41 {features.map((feature) => (42 <div43 key={feature.title}44 className="rounded-2xl border bg-background/80 p-6 shadow-sm backdrop-blur"45 >46 <div className="mb-4 flex size-10 items-center justify-center rounded-full border bg-muted">47 <CheckCircle2 className="size-5" />48 </div>4950 <h2 className="text-lg font-semibold">{feature.title}</h2>5152 <p className="mt-2 text-sm leading-6 text-muted-foreground">53 {feature.description}54 </p>55 </div>56 ))}57 </section>58 </main>59 </DotBackground>60 );61}6263const features = [64 {65 title: "Layered correctly",66 description:67 "The dot pattern sits behind the content while cards and text remain interactive and readable.",68 },69 {70 title: "Works with sections",71 description:72 "Multiple blocks can stack naturally without escaping the background wrapper.",73 },74 {75 title: "Responsive spacing",76 description:77 "The layout adapts from a single-column mobile view to a wider desktop grid.",78 },79];
Controls
size
dotSize
opacity
Installation & source
Install via the shadcn CLI or copy the registry files manually.
bash
npx shadcn@latest add @tt-ui/dot-background
Props
| Name | Type | Default | Description |
|---|---|---|---|
| size | number | 20 | Spacing between dots in pixels |
| dotSize | number | 1 | Radius of each dot in pixels |
| opacity | number | 0.18 | Foreground mix amount for dot color (0–1) |
| className | string | Additional classes for the dot overlay layer |