Astro Dot Pattern with Glow
A dot background that reveals a colored glow under the pointer.
Installation
bunx --bun shadcn@latest add @gnostic/dot-pattern-with-glownpx shadcn@latest add @gnostic/dot-pattern-with-glowpnpm dlx shadcn@latest add @gnostic/dot-pattern-with-glowCopy the files
src/components/patterns/dot-pattern-with-glow/dot-pattern-with-glow.astrosrc/components/patterns/dot-pattern-with-glow/index.tssrc/components/patterns/dot-pattern-with-glow/types.ts
Usage
The component is the positioned container. Move the pointer over it to show the glow. The slot renders inside that container, under the dot layers.
The pointer effect comes from Hover Glow. This component adds the base dots and a mask, so the color shows only inside each dot.
import { DotPatternWithGlow } from "@/components/patterns/dot-pattern-with-glow"
<DotPatternWithGlow class="h-72">
<p>Move the pointer</p>
</DotPatternWithGlow>
The glow color defaults to a 40 percent mix of var(--color-primary).
Pass var(--color-primary) when the glow should be stronger:
<DotPatternWithGlow class="h-72" glowColor="var(--color-primary)" />
The glow fades out when the pointer leaves the container or the window loses focus.
Examples
Larger glow
glowSize sets the glow radius. maskDotSize sets the radius of each glowing
dot. dotLayerProps sets the base dots and keeps the mask on the same grid.
API Reference
DotPatternWithGlowProps
glowColor?string
CSS color of the glow. Use the color's alpha value to set the glow opacity. The default keeps the glow soft.
string"color-mix(in oklch, var(--primary) 72%, transparent)"glowSize?number
Radius of the glow, in pixels.
number96maskDotSize?number
Radius of each dot in the glow mask, in pixels.
number1.25dotLayerProps?DotLayerProps
Props for the base dot layer.
DotLayerPropsSee the registry source for the component source.