Skip to content
iv-ui v0.3.0

Tabs

since 0.1.0

Switches between panels that share one context.

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

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>
  • 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.

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>
import { Tabs, TabList, Tab, TabPanel } from '@elluzion/iv-ui';

Tabs

5 props · 1 events · 1 snippets
PropTypeDefaultDescription
value bindablestring—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 booleanfalseDraws 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

EventHandler typeDescription
onchange(e: CustomEvent<{ value: string }>) => voidCalled with { value } after a tab is selected.

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

Snippets

SnippetTypeDescription
childrenSnippetContent rendered inside the component.

TabList

2 props · 0 events · 1 snippets
PropTypeDefaultDescription
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

SnippetTypeDescription
childrenSnippetThe tab buttons.

Tab

3 props · 0 events · 1 snippets
PropTypeDefaultDescription
value required string—Unique value matched by a tab panel.
disabled booleanfalsePrevents 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

SnippetTypeDescription
childrenSnippetTab label.

TabPanel

2 props · 0 events · 1 snippets
PropTypeDefaultDescription
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

SnippetTypeDescription
childrenSnippetPanel content.
KeysAction
TabMoves focus into the tab list.
Arrow left / rightMoves to the previous or next tab.
Home / EndMoves to the first or last tab.
Enter / SpaceSelects 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.
Class hooks
.iv-bordered.iv-tabs.iv-tab-list.iv-active.iv-md.iv-sm.iv-tab.iv-tab-panel
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records