Luca Perullo
Components

Component

LiveNew

Code Block

Code block stile editoriale: rounded-[9px], toolbar con chip lingua + file path, scroll cap a 480px e CopyButton (ghost). Modalità floatingCopy per nascondere il toolbar e mostrare il copy solo in hover.

CodeEditorialServer
Open in ClaudeSorgente

Esempio01

code-block.tsx
tssrc/lib/hello.ts
export function hello() {
  return "Ciao, mondo!";
}

Note Per blocchi long-form usa il toolbar (default). Per blocchi inline-prosa usa floatingCopy: il pulsante appare solo in hover/focus-within e il <pre> respira di più.

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 · code-block
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 <CodeBlock>: <pre> framato per documentazione.
Props:
- code: string
- filename?: string
- language?: string (default "tsx")
- maxHeight?: number (default 480)
- floatingCopy?: boolean

Layout: contenitore group/pre rounded-[9px] border bg-bg. Se filename o non floating: toolbar 32px in alto con chip lingua mono uppercase + file path text-fg-muted truncate. Pulsante Copy ghost in toolbar. Se floatingCopy: niente toolbar, copy in absolute top-2 right-2 con opacity-0 group-hover/pre:opacity-100. Pre m-0 px-4 py-4 font-mono text-[12.5px] leading-[1.65]. Container scrollabile con maxHeight CSS.

Constraints: server component, niente highlight (Plain pre), CopyButton client innestato, accessibile.

Output: file completo .tsx.

Uso tipico03

tsx
<CodeBlock code={code} filename="src/components/x.tsx" language="tsx" />

Dipendenze04

npm
  • tailwind-merge
  • clsx
Interno
  • @/components/copy-button#CopyButton
  • @/lib/utils#cn

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