CodeBlock

pro

CodeBlock highlights a single code snippet with a light/dark-aware theme, filename header, and copy button.

Installation

Add this component with the NateUI CLI.

npx nateui@latest add CodeBlock

Examples

Without Filename

Line Numbers

Multiple Languages

API

CodeBlock

PropDescriptionTypeDefault
codeThe source code to highlight.string—
languageShiki language id used for highlighting.string—
filenameOptional filename shown in a header row above the code.string—
showLineNumbersPrint a line number beside each row.booleanfalse
...divPropsStandard <div> attributes forwarded to the root.ComponentProps<'div'>—