1import { Button } from "@/components/ui/button";2import { toast } from "@/components/ui/toast";34export default function App() {5 return (6 <Button onClick={() => toast.success("Saved")}>7 Save changes8 </Button>9 );10}Installation
$ pnpm dlx shadcn@latest add @synccn/code-blockFirst time in this project? Connect synccn with one command.
Usage
import { CodeBlock } from "@/components/ui/code-block";<CodeBlock files={[{ name: "app.jsx", code, highlight: [3] }]} />API reference
Generated from the component's TypeScript types, so it always matches the code.
CodeBlock
Syntax-highlighted code with file tabs, copy, line numbers and highlighted lines. files: [{ name, code, highlight?: number[] }]. Uses the tiny sugar-high highlighter.
PropTypeDescription
- filesrequired
CodeFile[]One tab per file.
- lineNumbers
booleanDefault
trueShow line numbers.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/clipboardcopyText (copies to the clipboard)
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- sugar-high for highlight
- lucide-react for Check, Copy, FileCode2
Accessibility
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: tab, tablist
- ARIA attributes: aria-label, aria-selected
More display
CardSurface with header, content and footer slots.BadgeSmall status label with an optional dot.AvatarImage with initials fallback, presence dot and stacked groups.KbdKeyboard key for shortcuts and hints.SeparatorHorizontal, vertical or labelled divider.AccordionExpanding sections with smooth height animation.