Svelte Tabs - Bitblue

Organize content into tabbed panels with closable tabs and style variants

Each tab in tabs must provide a Svelte children component (not a snippet). Panel props are passed via props. Bind activeTab to control the selection.

Setup

<script lang="ts">
	import { Tabs } from '.';
</script>

Default tabs

Profile panel — pass a Svelte component via each tab’s children field.

<script lang="ts">
	import { Tabs } from '.';
	import Panel from './Panel.svelte'; // your panel component

	let activeTab = $state('profile');
	const tabs = [
		{ id: 'profile', title: 'Profile', children: Panel, props: { title: 'Profile' } },
		{ id: 'dashboard', title: 'Dashboard', children: Panel, props: { title: 'Dashboard' } },
		{ id: 'settings', title: 'Settings', children: Panel, props: { title: 'Settings' } }
	];
</script>

<Tabs bind:activeTab {tabs} tabStyle="underline" />

Tab styles

tabStyle: none (default), underline, pill, full.

pill

Day panel — pass a Svelte component via each tab’s children field.

full

Day panel — pass a Svelte component via each tab’s children field.

<script lang="ts">
	import { Tabs } from '.';
	import Panel from './Panel.svelte';
	let activeTab = $state('day');
	const tabs = [
		{ id: 'day', title: 'Day', children: Panel },
		{ id: 'week', title: 'Week', children: Panel }
	];
</script>

<Tabs bind:activeTab {tabs} tabStyle="pill" />

Closable tabs

Mark items with isClosable: true and handle onRemoveTab.

<script lang="ts">
	import { Tabs } from '.';
	import Panel from './Panel.svelte';

	let activeTab = $state('profile');
	let tabs = $state([
		{ id: 'profile', title: 'Profile', isClosable: true, children: Panel },
		{ id: 'settings', title: 'Settings', isClosable: true, children: Panel }
	]);
</script>

<Tabs
	bind:activeTab
	{tabs}
	tabStyle="underline"
	onRemoveTab={({ tabId }) => {
		tabs = tabs.filter((t) => t.id !== tabId);
		if (activeTab === tabId && tabs[0]) activeTab = tabs[0].id;
	}}
/>

Change callback

<script lang="ts">
	import { Tabs } from '.';
	import Panel from './Panel.svelte';
	let activeTab = $state('profile');
	const tabs = [{ id: 'profile', title: 'Profile', children: Panel }];
</script>

<Tabs
	bind:activeTab
	{tabs}
	onTabChange={(id) => console.log('active', id)}
/>

Props

Tabs (TabProps)

PropTypeDefaultDescription
tabsITab[][]Tab definitions (each needs children component)
activeTabstring | number0Bindable active tab id
tabStyle'none' | 'full' | 'pill' | 'underline''none'Visual style
dividerbooleantrueTheme divider under the tab list
hideTabsbooleantrueWhen false, the tab list is hidden (inverted name)
tabColorClassValue'bg-primary-500'Active tab color utility
tabClassClassValue—Classes on the tab list
tabActiveClass / tabInactiveClassClassValue—Per-state tab button classes
tabContentClassClassValue—Classes on every panel
tabContentActiveClass / tabContentInactiveClassClassValue—Active / inactive panel classes
onTabChange(tabId: string \| number) => void—Fired when selection changes
onTabAdd(val: any) => void—Passed through to panel components
onRemoveTab(val: RemoveTabEvent) => void—Closable tab callback

ITab

FieldTypeDescription
idstring | numberUnique tab id
titlestringTab label
childrenComponentPanel component (required)
iconstringOptional Iconify id
isClosablebooleanShow close control
propsRecord<string, any>Spread onto the panel component
stateRecord<string, any>Optional panel state bag

RemoveTabEvent

FieldTypeDescription
tabIdstring | numberClosed tab id
tabDataanyOptional payload
refreshbooleanOptional refresh hint

© 2026 Bitblue is a registered trademark. All Rights Reserved.