Luca Perullo
Components

Component

LiveNew

Grid Pattern

Pattern <path d='M.5 H V.5'/>. Prop squares: [col, row][] tinge le celle scelte con currentColor opacity 0.12.

BackgroundPattern
Open in ClaudeSorgente

Esempio01

grid-pattern.tsx
001Default · simple grid
002Highlighted · selected cells
003Dashed stroke · sketch feel

Note Le celle highlightate sono rect renderizzati DOPO il pattern, quindi sopra la griglia ma sotto il content. strokeDasharray utile per pattern punteggiati.

Prompt LLM02

Incolla in Claude o ChatGPT per generare la tua variante. Include il contesto del brand, i token e i vincoli del progetto.

Prompt · grid-pattern
Open in Claude
Sei un senior frontend engineer. Stai lavorando su un sito Next.js 16 + React 19 + Tailwind v4 in italiano, look chanhdai-inspired: colonna stretta 672px, Geist Sans + Geist Mono, hairline 1px, divisori a stripe diagonale, palette zinc.

Token CSS disponibili: --bg, --bg-alt, --fg, --fg-muted, --fg-soft, --border, --border-strong, --accent. Usa SEMPRE queste variabili tramite le utility tailwind generate (bg-bg, text-fg-muted, border-border, ecc.). Helper "cn" da "@/lib/utils". Niente librerie UI extra: solo lucide-react e tailwind-merge.

Genera un componente <GridPattern> SVG line-grid.
Props:
- width?: number, height?: number, x?, y?.
- strokeDasharray?: string.
- squares?: [number, number][] (cells da accendere).
- className?: string.

Implementazione:
- Server component, useId().
- <svg absolute inset-0 text-border> con <pattern id={id}><path d="M.5 {height}V.5H{width}" stroke="currentColor" fill="none" strokeDasharray={strokeDasharray}/></pattern> + <rect fill="url(#id)"/>.
- squares?.map(([col, row], i) → <rect x={col*width+1} y={row*height+1} width={width-1} height={height-1} fill="currentColor" opacity={0.12}/>).

Output: file completo src/components/grid-pattern.tsx.

Uso tipico03

tsx
<GridPattern squares={[[1,2],[3,4]]} strokeDasharray="4 2" />

Dipendenze04

npm
  • tailwind-merge
  • clsx
Interno
  • @/lib/utils#cn

Ti è servito? Dimmelo, oppure proponi il prossimo componente.