CodeBlock
CodeBlock renders syntax-highlighted source with an optional header, copy button, line numbers, highlighted and focused lines, diffs, folding and line selection.
Installation
Import from @gaudi/design-system. Load @gaudi/design-system/global.css once and add transpilePackages: ['@gaudi/design-system'] in Next.js.
Copy an example into your project with the shadcn CLI: npx shadcn@latest add https://design.gaudi.site/r/code-block-chat-references.json.
Usage
Examples
Quoted lines in a chat answer
Diagnostics with fixes
Find within a long file
Long file with folding
Line states
Code block options
Patch review
Streaming assistant reply
Tabbed code
Shell session with output
API
14 props
Accessibility
The code region is a labelled, keyboard-scrollable region; the copy, wrap, expand and download buttons have accessible names and announce their result. Line numbers, fold markers and decorations are hidden from assistive technology and never copied.
Related
TabsSwitch between related panels with keyboard-accessible tab controls.3 examplesCardCard frames reusable content with title, subtitle, and optional children.8 examplesScrollAreaContained scrolling with themed scrollbars and optional smooth wheel motion for article reading.2 examplesToggleGroupSingle or multiple pressed choices for view modes and compact formatting controls.6 examplesPillPill renders compact category and status labels.4 examplesFieldField composes form label, description, error, and input building blocks.7 examples