Skip to main content
161

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Data display

CodeTabs

Groups related code examples into accessible, persistent tabs.

FrameworksAstro · React · Elements

Registry commandlumen add CodeTabs

InteractionEnhanced runtime

01

See it and copy it

Framework example

Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroSame visual contract, native framework API
bash
pnpm add @santi020k/lumen-astro

Framework usage

Switch targets to compare the adapter code. The preview stays visually stable because all three packages share the same tokens and ui-* class contract.
astro
---
import { CodeTabs } from '@santi020k/lumen-astro'

const installCommands = [
  {
    code: 'pnpm add @santi020k/lumen-astro',
    label: 'pnpm',
    language: 'bash',
    value: 'pnpm'
  },
  {
    code: 'npm install @santi020k/lumen-astro',
    label: 'npm',
    language: 'bash',
    value: 'npm'
  },
  {
    code: 'yarn add @santi020k/lumen-astro',
    label: 'Yarn',
    language: 'bash',
    value: 'yarn'
  }
]
---

<CodeTabs
  ariaLabel="Package manager"
  items={installCommands}
  storageKey="preferred-package-manager"
/>
Edit CodeTabs in browser
02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add CodeTabs
lumen add CodeTabs

API reference

Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.

AttributeValuesDefaultDescription
itemsArray<{ code, label, language?, value }>requiredDefines the labelled code examples and their stable selection values.
ariaLabelstring"Code examples"Names the tab list for assistive technology.
initialValuestringfirst item valueSelects the matching code example before interaction.
storageKeystring-Persists selection and synchronizes CodeTabs instances that share this key.
copybooleantrueShows a copy button for each code example.
theme"auto" | "lumen" | "santi020k""auto"Selects the code palette family.
wrapbooleantrueWraps long code lines instead of requiring horizontal scrolling.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Keyboard interactions

Keyboard behavior provided by the Astro UIPrimitives runtime for this component.

KeyAction
ArrowRightActivate and focus the next code example, wrapping at the end.
ArrowLeftActivate and focus the previous code example, wrapping at the start.
Home, EndActivate and focus the first or last code example.

Web docsFull catalog