Dot Pattern

PreviousNext

A background utility component that renders a repeated dot pattern using SVG `<pattern>`. Useful for decorative backgrounds or UI sections.

dot-pattern-default

dot-pattern-custom

Installation

pnpm dlx shadcn@latest add https://ui.dalim.in/r/styles/default/dot-pattern.json

Usage

import { DotPattern } from "@/components/ui/dot-pattern"
<div className="relative h-64 w-full rounded-lg border">
  <DotPattern className="text-gray-300" />
  <div className="relative z-10 flex h-full items-center justify-center">
    <p className="text-lg font-medium">Content over dot background</p>
  </div>
</div>

API Reference

DotPattern

Renders a customizable repeating SVG dot pattern.

PropTypeDefaultDescription
widthnumber20The width of each pattern tile.
heightnumber20The height of each pattern tile.
xnumber0X-axis offset of the pattern.
ynumber0Y-axis offset of the pattern.
cxnumber1X coordinate of the dot inside the tile.
cynumber0.5Y coordinate of the dot inside the tile.
dotSizenumber0.7Radius of the dots.
classNamestringAdditional Tailwind/CSS classes applied to the <svg>.
...propsSVGProps<SVGSVGElement>Any additional props for the <svg>.