Astro Dot Pattern
A dot background that fills its container.
Installation
bunx --bun shadcn@latest add @gnostic/dot-patternnpx shadcn@latest add @gnostic/dot-patternpnpm dlx shadcn@latest add @gnostic/dot-patternCopy the files
src/components/patterns/dot-pattern/dot-pattern.astrosrc/components/patterns/dot-pattern/index.tssrc/components/patterns/dot-pattern/types.ts
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.
Custom colors
dotColor and dotBg accept any CSS color. The default dot color mixes
muted-foreground to 18 percent opacity.
Card background
Put the pattern inside a CardFrame + Card to have a subtle raised effect.
API Reference
DotPatternProps
PropType
dotSize?number
Radius of each dot, as a CSS size.
Type
numberDefault
1dotSpace?string
Distance from one dot to the next, as a CSS size. The tile is square, so this sets both axes.
Type
stringDefault
"1.5rem"dotColor?string
Valid CSS color string. Use an opaque color for better contrast.
Type
stringDefault
`color-mix(in srgb, var(--foreground) 16%, transparent)`dotBg?string
Valid CSS color string.
Type
stringDefault
"transparent"See the registry source for the component source.