---
title: "Tabs"
description: "Switches between panels that share one context."
category: "Layout & Navigation"
slug: tabs
url: /components/tabs
since: "0.1.0"
status: "stable"
---

# Tabs

Switches between panels that share one context.

## Import

```svelte
import { Tabs, TabList, Tab, TabPanel } from '@elluzion/iv-ui';
```

## Preview

An uncontrolled group with the first tab selected.

```svelte
<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>
```

## Usage

- `Tabs` owns the value; `TabList` holds `Tab` buttons; `TabPanel` shows matching content.
- Bind `value` for controlled state, or set `defaultValue` for an uncontrolled group.
- `bordered` wraps the list and panel in one frame.

## Examples

### Bordered

`bordered` frames the list and panel as one surface.

```svelte
<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.

```svelte
<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>
```

### Tabs

| 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 — Tabs

| Event | Handler type | Description |
| --- | --- | --- |
| `change` | `(e: CustomEvent<{ value: string }>) => void` | Called with `{ value }` after a tab is selected. |

The legacy `on:name` form is accepted for every event.

### Snippets — Tabs

| Snippet | Type | Description |
| --- | --- | --- |
| `children` | `Snippet` | Content rendered inside the component. |

### Tokens used

`--iv_border` · `--iv_radius`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-bordered` · `.iv-tabs`
### TabList

| 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 — TabList

| Snippet | Type | Description |
| --- | --- | --- |
| `children` | `Snippet` | The tab buttons. |

### Tokens used

`--iv_border` · `--iv_spacing-xs`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-tab-list`
### Tab

| 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 — Tab

| Snippet | Type | Description |
| --- | --- | --- |
| `children` | `Snippet` | Tab label. |

### Tokens used

`--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`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-active` · `.iv-md` · `.iv-sm` · `.iv-tab`
### TabPanel

| 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 — TabPanel

| Snippet | Type | Description |
| --- | --- | --- |
| `children` | `Snippet` | Panel content. |

### Tokens used

`--iv_foreground` · `--iv_foreground-dim` · `--iv_leading-base` · `--iv_outline-offset` · `--iv_outline-width` · `--iv_spacing-xl` · `--iv_text-body`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-bordered` · `.iv-tab-panel`

## 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 through `aria-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.

## Related

- [Accordion](/components/accordion.md)
- [ToggleGroup](/components/toggle-group.md)
- [ButtonGroup](/components/button-group.md)
- [Card](/components/card.md)