Data display
CodeTabs
Groups related code examples into accessible, persistent tabs.
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.
pnpm add @santi020k/lumen-astronpm install @santi020k/lumen-astroyarn add @santi020k/lumen-astroFramework usage
Switch targets to compare the adapter code. The preview stays visually stable because all three packages share the same tokens andui-* class contract.---
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"
/>import { CodeTabs } from '@santi020k/lumen-react'
export const Example = () => (
<>
<CodeTabs
ariaLabel="Package manager"
items={installCommands}
storageKey="preferred-package-manager"
/>
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-code-tabs
ariaLabel="Package manager"
items={installCommands}
storageKey="preferred-package-manager"></lumen-code-tabs>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.
pnpm add @santi020k/lumen-astropnpm add @santi020k/lumen-astrolumen add CodeTabslumen add CodeTabspnpm add @santi020k/lumen-reactpnpm add @santi020k/lumen-reactlumen add CodeTabs --target reactlumen add CodeTabs --target reactpnpm add @santi020k/lumen-elementspnpm add @santi020k/lumen-elementslumen add CodeTabs --target elementslumen add CodeTabs --target elementsAPI 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.
| Attribute | Values | Default | Description |
|---|---|---|---|
| items | Array<{ code, label, language?, value }> | required | Defines the labelled code examples and their stable selection values. |
| ariaLabel | string | "Code examples" | Names the tab list for assistive technology. |
| initialValue | string | first item value | Selects the matching code example before interaction. |
| storageKey | string | - | Persists selection and synchronizes CodeTabs instances that share this key. |
| copy | boolean | true | Shows a copy button for each code example. |
| theme | "auto" | "lumen" | "santi020k" | "auto" | Selects the code palette family. |
| wrap | boolean | true | Wraps long code lines instead of requiring horizontal scrolling. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML 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.
| Key | Action |
|---|---|
| ArrowRight | Activate and focus the next code example, wrapping at the end. |
| ArrowLeft | Activate and focus the previous code example, wrapping at the start. |
| Home, End | Activate and focus the first or last code example. |