Code

Code block

Shiki with the kit's own light and dark themes, switched by CSS, so a theme change never re-highlights. Plain text renders first in the exact same layout, so nothing shifts when colors arrive; streamed code highlights as it comes in.

Live example

Import

Each family is its own entry point, so a page loads only what it uses.

tsx
import { Button } from "@nibapp/ui/components/button";import { Code, CodeBlock } from "@nibapp/ui/components/code-block";import { CopyButton } from "@nibapp/ui/components/copy-button";import { CopyCommand } from "@nibapp/ui/components/copy-command";

Props

Each component's own props and variants, read from its source. What it also takes from an element or a Base UI part is named below its table.

Button

PropTypeDefaultDescription
variant"primary" | "secondary" | "ghost" | "quiet" | "danger" | "danger-ghost" | "link""secondary"
primary
Neutral ink: the main call to action. Actions are ink, never the accent.
secondary
Quiet surface with a hairline — the default for most actions.
ghost
No chrome until hovered — toolbars, inline actions.
quiet
Words that are also an action, in the text's own weight and laid out from the start, so they line up with the text around them: `xs` in a line (a header's crumbs, a title that renames), `sm` a toolbar's picker, `md` a row in a list or a popover ("Open settings", a sidebar's link).
danger
Destructive confirmation.
danger-ghost
Destructive but low emphasis.
link
Inline text action.
size"xs" | "sm" | "md" | "lg""md"
blockboolean—
truncateboolean—

The button may shrink below its label's width; the label then truncates with an ellipsis.

wrapboolean—

The label wraps onto more lines and the button grows, its `leading` icon on the first line: for words that are an action and may run long in another language (a tip). One line keeps the size.

loadingbooleanfalse

Shows a spinner, keeps the button's width, and blocks interaction.

leadingReactNode—

Icon rendered before the label.

trailingReactNode—

Icon or hint (e.g. <Kbd>) rendered after the label.

disabledReasonstring | undefined—

Disables the button and says why: the reason is its tooltip and its accessible description, and the button stays focusable (`aria-disabled`) so a keyboard reaches it.

Also takes .

Code

Inline code span for prose: hairline chip, mono, slightly smaller than surrounding text.

Also takes the props of a <code> element.

CodeBlock

PropTypeDefaultDescription
code (required)string—

Source text. A single trailing newline is ignored.

langstring | undefined—

Language id or fence info (`ts`, `tsx`, `python`, `sh`, …). Unknown → plain text.

filenamestring | undefined—

Shown in the header instead of the language.

showLineNumbersbooleanfalse
startLinenumber1

Number of the first line (e.g. a Read from offset 120). Default 1.

highlightLinesreadonly number[]—

1-based line numbers to emphasize (in the same numbering as `startLine`).

wrapbooleanfalse

Soft-wrap long lines instead of scrolling horizontally.

maxHeightnumber | string—

Scroll vertically beyond this height (e.g. `320` or `"40vh"`).

streamingbooleanfalse

The code is still arriving: incremental highlighting, line fade-in, stick-to-bottom.

headerbooleantrue

Render the header bar (label + copy). Without it, copy floats in on hover.

actionsReactNode—

Extra controls rendered in the header, before the copy button; text among them wraps, and the header grows.

Also takes the props of a <div> element, except children.

CopyButton

Icon button that copies `value` and confirms with a check.

PropTypeDefaultDescription
value (required)string | (() => string)—

Text to copy, or a getter evaluated on click (for large/derived values).

labelstring—

Accessible + tooltip label (default `codeBlock.copy`).

Also takes IconButtonProps, except aria-label, children, value and onClick.

CopyCommand

A command to paste into a terminal as one button: the prompt, the command and the copy mark. The check that confirms the copy draws in the accent, one of its few uses, and a polite live region says it was copied.

PropTypeDefaultDescription
command (required)string—

The command copied and shown.

promptstring | undefined"$"

Written before it and left out of the copy (`$`); `""` for none.

labelstring | undefined—

What copying does ("Copy install command"); the name is it and the command, so it holds the text the button shows. Default: "Copy <command>".

classNamestring | undefined—