Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Astro Dot Pattern

A dot background that fills its container.

Dot pattern

Installation

bunx --bun shadcn@latest add @gnostic/dot-pattern

Usage

Place the pattern inside a positioned parent. The element uses absolute inset-0 and fills that parent.

import { DotPattern } from "@/components/patterns/dot-pattern"
<div class="relative h-72 overflow-hidden">
  <DotPattern />
</div>

Examples

Larger dots

dotSize sets the dot radius in pixels. dotSpace sets the distance from one dot to the next.

Larger dots

Custom colors

dotColor and dotBg accept any CSS color. The default dot color mixes muted-foreground to 18 percent opacity.

Custom colors

Card background

Put the pattern inside a CardFrame + Card to have a subtle raised effect.

Dot pattern card

API Reference

DotPatternProps

PropType
dotSize?number

Radius of each dot, as a CSS size.

Typenumber
Default1
dotSpace?string

Distance from one dot to the next, as a CSS size. The tile is square, so this sets both axes.

Typestring
Default"1.5rem"
dotColor?string

Valid CSS color string. Use an opaque color for better contrast.

Typestring
Default`color-mix(in srgb, var(--foreground) 16%, transparent)`
dotBg?string

Valid CSS color string.

Typestring
Default"transparent"

See the registry source for the component source.