A composable code panel with header, copy button, line variants, and optional Shiki highlighting.
Terminal
$ bun install
$ bun run buildInstallation
npx shadcn@latest add https://reactdocs.canceydejean.dev/r/code-block.jsonUsage
Compose a terminal or source panel with a title, copy action, and content.
import {
CodeBlock,
CodeBlockActions,
CodeBlockContent,
CodeBlockCopyButton,
CodeBlockHeader,
CodeBlockTitle,
} from "@/components/ui/code-block/code-block";
const output = `$ bun install
$ bun run build`;
export function Example() {
return (
<CodeBlock>
<CodeBlockHeader>
<CodeBlockTitle>Terminal</CodeBlockTitle>
<CodeBlockActions>
<CodeBlockCopyButton value={output} />
</CodeBlockActions>
</CodeBlockHeader>
<CodeBlockContent>{output}</CodeBlockContent>
</CodeBlock>
);
}Use variant="destructive" for error output. Pass lineNumbers on CodeBlockContent for numbered
plain text, or pair with use-highlighted-code and CodeBlockLine for Shiki tokens. Install
scroll-fade so horizontal fade classes apply.