Code Tabs
Tabbed code snippets with per-tab copy and a localStorage-synced tab choice.
Import
import { CodeTabs } from "@cooud-ui/ui";
npx cooud-ui add code-tabs
Examples
API Reference
Generated from the component's exported types.
CodeTabsProps
Extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "defaultValue" | "dir" | "onChange">
| Prop | Type | Default | Description |
|---|---|---|---|
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. |