CodeBlock
Code or command output with a copy button.
Installation
Install CodeBlock from the Fluid Effect UI registry.
Basic
tsx
greeting.tsx
Highlighted
This example passes Shiki-highlighted nodes as children. Copy code uses the original source text.
tsx
Output
API Reference
Types come from the public API. A dash indicates no default is documented here.
CodeBlock props
Public source| Prop | Type | Default |
|---|---|---|
id | string | Required |
code | string | Required |
language | string | 'plaintext' |
title | string | View.Content<Msg, R> | props.filename |
filename | string | — |
children | View.Children<Msg, R> | — |
lineNumbers | boolean | — |
wrap | boolean | — |
maxHeight | number | — |
hideHeader | boolean | — |
showLineCount | boolean | — |
label | string | props.filename |
className | string | — |
copyControl | View.Content<Msg, R> | — |
onCopied | NoInfer<Msg> | — |
onCopyFailed | NoInfer<Msg> | — |
shape | ShapeVariant | 'rounded' |
size | SizeVariant | 'default' |
surface | number | 1 |