Grid Pattern

A background grid pattern made with SVGs, fully customizable using Tailwind CSS.

Installation

pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/grid-pattern.json

Usage

<script lang="ts">	import { GridPattern } from "#lib/components/magic/grid-pattern/index.js";</script>
<div class="relative h-64 overflow-hidden">	<GridPattern class="absolute inset-0" /></div>

Props

Grid Pattern Props

Props for the GridPattern component

NameTypeDefaultDescription
widthnumber40The width of each grid cell
heightnumber40The height of each grid cell
xnumber-1The x-offset of the pattern
ynumber-1The y-offset of the pattern
squaresArray<[x: number, y: number]>undefinedArray of [x, y] coordinates for highlighted squares
strokeDasharraystring"0"Stroke dash array for dashed lines
classClassValueundefinedAdditional CSS classes