Skip to content
Data Display

Code Tabs

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

Import

tsx
import { CodeTabs } from "@cooud-ui/ui";
bash
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">

Skip CodeTabsProps props table
PropTypeDefaultDescription
items*
CodeTabsItem[]The snippets to switch between — one tab + one panel per item.
defaultLabel
stringLabel 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
stringPersist 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) => voidCalled with the newly selected label on user-initiated changes.