Code
Syntax-highlighted code block and folder explorer.
Group multiple code blocks into an IDE-like folder explorer.
Use a single code block for short examples.
Usage#
Inline Code#
Add a language attribute to highlight code within a sentence: const count = 1.
Use Ref<string> to highlight a TypeScript type fragment.
Code Block#
Write a fenced code block with a language for syntax highlighting.
Header#
Add a filename in square brackets to show a header, or omit it for a headerless block.
Line Numbers#
Set lineNumbers=true to show line numbers.
Line Highlights & Diffs#
Use added, deleted, and highlighted ranges to highlight particular lines.
Compact#
Set compact=true to align the block's borders with the text column without changing its inner padding. This only affects standalone blocks on desktop.
Code Group#
Wrap related code blocks in CodeBlockGroup. File paths dictate the folder structure.
Set the group's lineNumbers to true to enable numbers for every file, or false to hide them. Each fence keeps its own annotation ranges.
Code Tabs#
Wrap standalone fences, complete code groups, or terminals in CodeTabs. The tab row belongs to the outer frame. Files inside a code group keep their normal headers.
Fences use their filename and language icon as the tab label. Groups use title; terminals use title or their shell name. The selected label changes color without changing weight or adding an indicator.
Synchronization#
Use the same syncID and explicit syncValue values on CodeTabs and ordinary Tabs. Selecting either updates all matching groups and persists the choice in local storage. A group without the selected value shows its first option without overwriting the shared preference.
Groups with Tabs#
Place entire CodeBlockGroup components inside CodeTabs, with a title and syncValue on each group. Individual files cannot contain tab groups.
Terminals with Tabs#
Terminal options retain their own prompts, recordings, and copy controls. Put syncValue on the Terminal, not its steps.
Code Tabs Reference#
syncIDDefaultundefinedstringShare selection with Tabs and CodeTabs using the same ID and syncValue options.
compactDefaultfalsebooleanAlign the desktop frame with the content column.
Code Block Reference#
syncValueDefaultundefinedstringSelection value when this surface is a direct child of synchronized CodeTabs.
filenameDefaultundefinedstringFile path shown in the header. Omit for a headerless block.
languageDefaultundefinedstringSyntax-highlighting language. Omit for plain text.
lineNumbersDefaultfalsebooleanShow line numbers. A group controls this for all its files.
compactDefaultfalsebooleanAlign borders with the content column without changing inner padding. Only affects standalone blocks on desktop.
addedDefaultundefinedstringOne-based line ranges tinted with the
positivecolor role.
deletedDefaultundefinedstringOne-based line ranges tinted with the
negativecolor role. Text remains available for copying.
highlightedDefaultundefinedstringOne-based line ranges tinted with the
accentcolor role. Each line can have only one annotation.
Code Group Reference#
titleDefaultundefinedstringTab label when this group is a direct child of CodeTabs.
syncValueDefaultundefinedstringSelection value when this surface is a direct child of synchronized CodeTabs.
lineNumbersDefaultfalsebooleanDisplay line numbers for every fence in the group.