Skip to content
VenusUI
Get started

Grid Pattern

Grid lines as a background, with optional highlighted cells and an edge fade.

Preview

Installation

npx shadcn@latest add @venusui/grid-pattern

Run this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.

Files added to your project

Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.

  • @/components/ui/grid-pattern.tsx

Usage

The code behind the preview above.

grid-pattern-demo.tsx

import { GridPattern } from "@/components/ui/grid-pattern"

export default function GridPatternDemo() {
  return (
    <div className="relative flex h-56 w-full max-w-lg items-center justify-center overflow-hidden rounded-xl border bg-background">
      <GridPattern fade highlight={[[3, 1], [5, 2], [8, 1], [10, 3]]} />
      <p className="relative text-lg font-medium">Grid pattern</p>
    </div>
  )
}

API reference

PropTypeDefaultDescription
sizenumber32Cell size, in pixels.
highlight[number, number][][]Cells to fill, as [column, row] pairs from the top-left.
dashedstring—SVG dash pattern for the lines, e.g. "4 2".
fadebooleanfalseFade the grid out from the top center.

All <svg> props, including className and style.

Requirements

  • Tailwind CSS v4, with a cn helper at @/lib/utils. Works in Server Components.

Customization

  • Lines and highlighted cells use currentColor; set it with a text class such as text-border.
  • Highlight cells near your headline to draw the eye, e.g. highlight={[[4, 2], [6, 3]]}.

Accessibility

  • Decorative: aria-hidden and ignores the pointer.

Troubleshooting

Highlighted cells don’t line up with the grid.
Cells are counted from the top-left of the SVG. If you offset the pattern, offset the highlights the same way.
Unknown registry "@venusui"
Your shadcn CLI couldn’t find the namespace in the shadcn registry index. Use the latest CLI (npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.
No components.json found
Run npx shadcn@latest init in your project first.
Loading preview

A dotted 3D Earth with glowing routes between cities; pulses travel each arc and ripple where they land.

Loading preview

Soft, blurred color fields that drift slowly behind content.

Loading preview

Background Beams

Backgrounds

Curved lines across a section with light traveling along them.