New
A high-performance syntax-highlighted code surface powered by Shiki with zero-DOM CSS line numbers, dual themes, line highlighting, collapsible blocks, diff mode, code folding, diagnostic levels, and copy actions.
Installation
$ pnpm dlx shadcn@latest add @byphongphan/code-block
Requires @byphongphan in components.json
Anatomy
Usage
API Reference
CodeBlock
The root container managing syntax highlighting, Shiki streaming, CSS counter state, and context providers.
CodeBlockContent
Composable surface that renders the code block inside an external scroll wrapper (e.g. ScrollArea).
Top toolbar header housing filename title, language tag, and action buttons.
CodeBlockTitle
Displays the file name or snippet label with standard typography.
CodeBlockLanguage
Displays the detected or specified syntax language badge.
Interactive clipboard button with animated copied state feedback.
Downloads the current code block content as a local file.
CodeBlockWrapToggle
Toggles soft line-wrapping on and off.
Floating expand/collapse control rendered when maxLines clamps code block height.
CodeBlockLineActions
Render prop registering custom action controls on hovered/active code lines.
References