ZUI

Search documentation

Find a page or a heading.

Code Card

Read-only source over a collapsible card, highlighted through the shared Shiki highlighter and falling back to plain mono while the grammar loads.

tsx

Installation

bash

Usage

tsx

The root holds the code; its parts show it. Compose a header from CollapsibleCard parts, then the body:

tsx

A block with no header floats its copy action over the code instead, inside CodeCardActions placed before CodeCardContent: <CodeCardActions><CodeCardCopy variant="secondary" /></CodeCardActions>. Use it for a self-contained, read-only block; for already-tokenized source with no card chrome, compose HighlightedCode directly.

Composition

text

API reference

CodeCard

Renders CollapsibleCard and takes every prop it takes, plus:

It defaults variant to muted. It sets data-slot="code-card" and data-language to its language.

CodeCardActions

Renders a div and takes every prop a div takes. It floats over the code's top-right corner, shown while the block is hovered or one of its children holds keyboard focus; use it for a block with no header. It sets data-slot="code-card-actions".

CodeCardContent

Renders CollapsibleCardContent and takes every prop it takes. Its viewport scrolls the code both ways and carries data-slot="code-card-viewport". It sets data-slot="code-card-content".

CodeCardLineNumbers

Renders a span and takes every prop a span takes. It numbers every line of the block's code, at least three digits wide, hidden from assistive technology and left out of a copy. It sets data-slot="code-card-line-numbers" and aria-hidden.

CodeCardCode

Renders HighlightedCode and takes every prop it takes except lines and children, which it supplies from the block's code and highlighted lines. It sets data-slot="code-card-code".

CodeCardLanguage

Renders a span and takes every prop a span takes. It shows the block's language as an icon and display name, "Plain text" when it has none; children replace the name. It sets data-slot="code-card-language".

CodeCardCopy

Renders CopyButton and takes every prop it takes except value, which it supplies as the block's code. label defaults to Copy code and size to icon. It sets data-slot="code-card-copy".