Skip to content
Binary Dreams UI Kit reference CodeBlock

Code block

Read-only source starts collapsed and opens from its header button.

Loading interactive example

Choose CodeBlock for read-only code that readers may need to copy. The code body fades in when opened. The native hidden state closes it immediately. highlightLines uses one-based source line numbers and ignores invalid or duplicate entries. The highlighter receives the complete source; return its original text and newlines with inline styles that preserve text metrics. Copy always uses the original source.

API

MemberTypeKindRequiredDefault
codestringpropYes
copyLabelstringpropNo'Copy code'
copyablebooleanpropNotrue
filenamestringpropNoundefined
highlight(code: string, language: string) => stringcallbackNoundefined
highlightLinesreadonly number[]propNo[]
labelstringpropNoundefined
languageCodeLang | (string & {})propNo'text'
maxHeightnumberpropNoundefined
openbooleanbindingNofalse
showLineNumbersbooleanpropNofalse
wrapbooleanpropNofalse

Examples

Source

Loading source