shadcn Code Block

Displays code, terminal output and diffs with an optional header, line numbers and a copy button. Preview it in Figma or edit it in DS Manager with your own tokens.

Code Block shadcn/ui component in FigmaLoading the Figma preview…

In the Figma kit

Variants: default and destructive. Sizes: default and sm. Optional header with title icon and copy button, floating actions, footer, and lines that can be numbered, highlighted, added or removed. The Figma component uses the same variant and size names as the React code, so the design maps directly to the component in your project.

Figma kitReact8 stylesLast updated 21 Oct 2026

Code Block component for shadcn/ui in Figma

Code Block shows source code, terminal output and diffs. It has an optional header with a title and actions, a copy button, line numbers, highlighted, added and removed lines, and a footer. Use the sm size for tool output inside Trace.

FAQs

Which variants and sizes does Code Block have?

Two variants, default and destructive, and two sizes, default and sm. The sm size is meant for tool output inside a Trace.

How do line numbers and diffs work?

Every line is a CodeBlock / Line instance with the variants default, highlighted, added and removed, plus a Show Line Number toggle. Added lines use the same tint as highlighted lines with a + marker, and removed lines use a destructive tint with a − marker.

Can I hide the header?

Yes. Turn off Show Header and turn on Show Floating Actions to keep the copy button in the top corner, the way CodeBlockActions works without a header in code.

Does the Figma component include syntax colors?

No. All code uses the foreground color. In code, syntax colors come from Shiki's GitHub Light and Dark themes, which are not shadcn/ui theme tokens.