Skip to content
Data Display

Code Block

Source snippet with header, line numbers and copy.

Import

tsx
import { CodeBlock } from "@cooud-ui/ui";
bash
npx cooud-ui add code-block

Examples

API Reference

Generated from the component's exported types.

CodeBlockProps

Extends Omit<HTMLAttributes<HTMLDivElement>, "children">

PropTypeDefaultDescription
code*
stringRaw source to render and copy.
language
stringLanguage label rendered as a Badge in the header.
filename
stringFile name rendered in the header.
showLineNumbers
booleanfalseRender a gutter with 1-based line numbers. Defaults to false.