Data | CodeBlock
CodeBlock#
Description#
Component for displaying machine text: a growing log, a command, a configuration file. Accepts a plain text block (text) or a list of lines with tone (lines). The tone does not paint the text (for contrast reasons), but marks a colored strip on the left side of the line. With maxHeight the block scrolls internally and is tabbable; with follow it stays pinned to the end as new lines arrive, unless the user has scrolled up to read.
Props#
text(string) — Plain text block. Default:''.lines(readonly CodeLine[]) — List of lines withtextand optionaltone('neutral'|'muted'|'info'|'success'|'warning'|'error'). Default:[].wrap(boolean) — Wraps long lines. Withoutwrap, lines stay intact and the block scrolls horizontally. Default:true.maxHeight(string | number) — Maximum CSS height or pixels. Without it, grows with content. Default:undefined.follow(boolean) — Keeps the view pinned to the end when new content arrives. Default:false.variant('code'|'log') —logusesrole="log"to announce new content without interrupting. Default:'code'.label(string) — Region name for accessibility. Default:undefined.
Usage#
| |
Notes#
linestakes precedence overtext: if both are present, lines are shown.- With
maxHeightthe block is tabbable (tabindex="0") for keyboard reading. muteddims the text; other tones only change the left strip.