Skip to content
Display

Code Tabs

Tabbed code snippets with per-tab copy and a localStorage-synced tab choice.

Import

tsx
import { CodeTabs } from "@cronus-ui/ui";
bash
npx cronus-ui add code-tabs

Examples

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 1/1Pixel diff 0 pxLogic 1/1Parity scoreboard
default.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component CodeTabsDefault layout:inline style:code-tabs {
  aria-label:"Install"
  label "Install"
  text "bun"
  text "npm"
}

page "/audit/code-tabs/default" type:custom {
  use CodeTabsDefault
}

API Reference

Generated from the component's exported types.

CodeTabsProps

Extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "defaultValue" | "dir" | "onChange">

Skip CodeTabsProps props table
PropTypeDefaultDescription
items*
CodeTabsItem[]—The snippets to switch between — one tab + one panel per item.
defaultLabel
string—Label selected on first render. Falls back to the first item when omitted or unknown. When is set, a stored choice (applied after mount) wins over this.
storageKey
string—Persist the chosen label to `localStorage` under this key and keep every `CodeTabs` sharing the key in sync — across the page *and* across browser tabs. The stored value is only read after mount, so server-rendered HTML and the first client render always agree (no hydration mismatch).
onLabelChange
(label: string) => void—Called with the newly selected label on user-initiated changes.
className
string—Additional class names merged onto the root.
id
string—DOM id of the root element.