Code or a command with a copy button: wraps a command between words, scrolls source sideways, hides a one-time secret until shown. Takes a highlighter's output as children.
Code block command
Install
npx shadcn add @syncrobotic/code-block Also installs: lucide-react, @syncrobotic/cn, @syncrobotic/button, @syncrobotic/copy-button, @syncrobotic/table
Overview
Code or a command to read and copy, in a frame with its title and a copy button.
When to use
- Install and import commands (dvc import, npx shadcn add) and curl examples.
- A one-time API key or webhook secret, hidden until shown.
- Source and API responses in docs and settings pages.
Use something else
- A short value inline (an ID, a reference): Copy button beside the text.
- A value someone edits: Input or Textarea.
More examples
States and real uses. Each example is also a Storybook story and a visual regression test.
Code block scrolls
Code block with title
Code block secret
Code block curl
Usage rules
- Copy copies
codeexactly, whatever the block shows: highlighted children, wrapped lines or a hidden secret. - wrap="words" for shell commands, so a phone never cuts a package name in two; wrap="none" for source, which scrolls sideways with a fade on the side that hides text.
- A one-time secret (an API key) is
secret: dots until Show is pressed. Never put the value in the title or a label; say beside it that it is shown once. - No highlighter inside: pass shiki's output (or any
<pre>) as children. Line numbers only for source people discuss by line.
Changelog
- 0.19.02026-11-20labels.copy(title) names the copy button, so it can be translated; copyLabel still sets it as is.
- 0.18.02026-11-19First release: a framed block with a title and CopyButton; wrap="words" for shell commands, wrap="none" scrolls with the table's fade and takes focus; secret hides a one-time value behind Show; optional line numbers; a highlighter's output (shiki) as children.