Skip to content

Tabs

Tab panels with labels, custom values and default index.

Tabs switch panels client-side via the runtime — no page reload. The tab list is role="tablist" with proper aria-selected state.

Items only
tabs({ items: ['Preview', 'Code', 'Notes'] });
Panels + label
Package manager
bun add @iconify-json/lucide
npm install @iconify-json/lucide
pnpm add @iconify-json/lucide
tabs({
label: 'Package manager',
panels: [
{ title: 'bun', content: code('bun add @iconify-json/lucide') },
{ title: 'npm', content: code('npm install @iconify-json/lucide') },
{ title: 'pnpm', content: code('pnpm add @iconify-json/lucide') },
],
});
defaultIndex = 2

Install and configure.

Import and call the builder.

Override icons and labels.

tabs({
defaultIndex: 2,
panels: [
{ title: 'Setup', content: '<p>Install and configure.</p>' },
{ title: 'Usage', content: '<p>Import and call the builder.</p>' },
{ title: 'Advanced', content: '<p>Override icons and labels.</p>' },
],
});
OptionTypeDefaultDescription
itemsstring[]Tab titles when panels is omitted.
panelsTabPanel[]{ title?, value?, content } — content can be HTML.
labelstring''Optional group label before the tab list.
defaultIndexnumber0Initially active tab.
  • value (when set) is used as the data-cpd-tab value; otherwise it is derived from the title (title.toLowerCase().replace(/\s/, '-')).
  • Panels with no content (items-only mode) render an empty active panel.