What it does
Wraps children in pre/code with padded, bordered surfaces.
Overflow-x keeps wide snippets usable on mobile.
Composition and API
Tone adjusts text color consistently with other typography primitives.
Extend via className when embedding inside cards.
Common use cases
- Installation commands.
- JSON payloads in docs.
- Diff excerpts for reviews.
- Sample env blocks with warnings.
Accessibility
Labels describe the snippet purpose.
Ensure focus order still reaches surrounding explanatory text.
Next.js integration notes
Avoid importing massive highlighters into server layouts unnecessarily.
Lazy-load heavy highlighting clientside when needed.
FAQ
Does CodeBlock highlight syntax?
Not by default—pipe highlighted nodes as children or integrate a highlighter in your app shell.
How does language prop help?
It shapes aria-label text for assistive technologies and future highlighting integrations.
Can children include JSX?
Pass plain text children for simplest cases; advanced highlighting may inject spans inside code.