Tabs
Switches between panels that share one context.
import { Tabs, TabList, Tab, TabPanel } from '@elluzion/iv-ui'; 01 Preview
Basic
An uncontrolled group with the first tab selected.
Runtime, regions, and the current release.
Source· svelte Show Hide
<script lang="ts">
import { Tab, TabList, TabPanel, Tabs } from '@elluzion/iv-ui';
</script>
<Tabs defaultValue="overview">
<TabList label="Project sections">
<Tab value="overview">Overview</Tab>
<Tab value="deploys">Deployments</Tab>
<Tab value="settings">Settings</Tab>
</TabList>
<TabPanel value="overview">Runtime, regions, and the current release.</TabPanel>
<TabPanel value="deploys">Every run, with the commit and the duration.</TabPanel>
<TabPanel value="settings">Access, retention, and the deploy key.</TabPanel>
</Tabs>02 Usage
Tabsowns the value;TabListholdsTabbuttons;TabPanelshows matching content.- Bind
valuefor controlled state, or setdefaultValuefor an uncontrolled group. borderedwraps the list and panel in one frame.
03 Examples
Bordered
bordered frames the list and panel as one surface.
12:04:18 deploy started
Source· svelte Show Hide
<script lang="ts">
import { Tab, TabList, TabPanel, Tabs } from '@elluzion/iv-ui';
</script>
<Tabs defaultValue="logs" bordered>
<TabList label="Output">
<Tab value="logs">Logs</Tab>
<Tab value="trace">Trace</Tab>
</TabList>
<TabPanel value="logs">12:04:18 deploy started</TabPanel>
<TabPanel value="trace">build → test → publish (4.2s)</TabPanel>
</Tabs>Sizes
sm and md tab heights.
Small tab content.
Medium tab content.
Source· svelte Show Hide
<script lang="ts">
import { Tab, TabList, TabPanel, Tabs } from '@elluzion/iv-ui';
</script>
<div class="stack">
<Tabs defaultValue="one" size="sm">
<TabList label="Small tabs">
<Tab value="one">One</Tab>
<Tab value="two">Two</Tab>
</TabList>
<TabPanel value="one">Small tab content.</TabPanel>
<TabPanel value="two">Second panel.</TabPanel>
</Tabs>
<Tabs defaultValue="one">
<TabList label="Medium tabs">
<Tab value="one">One</Tab>
<Tab value="two">Two</Tab>
</TabList>
<TabPanel value="one">Medium tab content.</TabPanel>
<TabPanel value="two">Second panel.</TabPanel>
</Tabs>
</div>
<style>
.stack {
display: flex;
flex-direction: column;
gap: var(--iv_spacing-xl);
}
</style>04 API
import { Tabs, TabList, Tab, TabPanel } from '@elluzion/iv-ui';Tabs
5 props · 1 events · 1 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| value bindable | string | — | Selected tab value. Bind with bind:value. |
| defaultValue | string | '' | Selected tab value on first render when uncontrolled. |
| size | 'sm' | 'md' | 'md' | Tab height and padding. |
| bordered | boolean | false | Draws a border around the tab list and panel. |
| className | string | '' | Extra classes merged onto the root element. |
class, id, style, aria-*, and data-* are forwarded through rest props.
Events
| Event | Handler type | Description |
|---|---|---|
| onchange | (e: CustomEvent<{ value: string }>) => void | Called with { value } after a tab is selected. |
The legacy on:name form is accepted for every event.
Snippets
| Snippet | Type | Description |
|---|---|---|
| children | Snippet | Content rendered inside the component. |
TabList
2 props · 0 events · 1 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | '' | Accessible name for the tab list. |
| className | string | '' | Extra classes merged onto the root element. |
class, id, style, aria-*, and data-* are forwarded through rest props.
Snippets
| Snippet | Type | Description |
|---|---|---|
| children | Snippet | The tab buttons. |
Tab
3 props · 0 events · 1 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| value required | string | — | Unique value matched by a tab panel. |
| disabled | boolean | false | Prevents selection and removes the tab from the tab order. |
| className | string | '' | Extra classes merged onto the root element. |
class, id, style, aria-*, and data-* are forwarded through rest props.
Snippets
| Snippet | Type | Description |
|---|---|---|
| children | Snippet | Tab label. |
TabPanel
2 props · 0 events · 1 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| value required | string | — | Value of the tab that controls this panel. |
| className | string | '' | Extra classes merged onto the root element. |
class, id, style, aria-*, and data-* are forwarded through rest props.
Snippets
| Snippet | Type | Description |
|---|---|---|
| children | Snippet | Panel content. |
05 Accessibility
| Keys | Action |
|---|---|
| Tab | Moves focus into the tab list. |
| Arrow left / right | Moves to the previous or next tab. |
| Home / End | Moves to the first or last tab. |
| Enter / Space | Selects the focused tab. |
- The list uses
role="tablist"; each tab controls a panel througharia-controls. - Only the active tab is in the tab order; arrow keys provide the rest of the navigation.
- Panels use
role="tabpanel"and are labelled by their tab.
06 Tokens & CSS hooks
Tokens used
--iv_border --iv_radius --iv_spacing-xs --iv_cursor --iv_disabled-opacity --iv_ease-out --iv_font-ui --iv_foreground --iv_foreground-dim --iv_outline-width --iv_radius-sm --iv_reverse-bg --iv_reverse-fg --iv_spacing-md --iv_spacing-sm --iv_text-body --iv_text-btn-sm --iv_transition-fast --iv_leading-base --iv_outline-offset --iv_spacing-xl
Class hooks
.iv-bordered.iv-tabs.iv-tab-list.iv-active.iv-md.iv-sm.iv-tab.iv-tab-panel