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-astroView CodeTabs code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
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
recoveryLabel="Select and copy the complete example"
ariaLabel="Package manager"
items={installCommands}
storageKey="preferred-package-manager"
/>import { CodeTabs } from '@santi020k/lumen-react'
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'
}
]
export const Example = () => (
<>
<CodeTabs
recoveryLabel="Select and copy the complete example"
ariaLabel="Package manager"
items={installCommands}
storageKey="preferred-package-manager"
/>
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-code-tabs
recovery-label="Select and copy the complete example"
aria-label="Package manager"
items={installCommands}
storage-key="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-astroScroll horizontally to read more
lumen add CodeTabsScroll horizontally to read more
pnpm add @santi020k/lumen-reactScroll horizontally to read more
lumen add CodeTabs --target reactScroll horizontally to read more
pnpm add @santi020k/lumen-elementsScroll horizontally to read more
lumen add CodeTabs --target elementsScroll horizontally to read more
API reference
Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.
Scroll horizontally to compare
| Attribute | Values | Default | Description |
|---|---|---|---|
| recoveryLabel | string | - | Forwards manual-copy recovery to each code example and clears stale recovery when changing tabs. Elements uses recovery-label on lumen-code-tabs. |
| 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.
Scroll horizontally to compare
| 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. |