Skip to content
portalbits
Home Docs GitHub(opens in a new tab)

Guides

Get startedFoundationsMotion

Components

All components

Buttons

ButtonIconButton

Inputs

InputSelectTextareaSlider

Selection

CheckboxToggleToggleGroupSwitchRadioGroup

Identity

AvatarBadge

Overlays

DialogPopoverTooltipDropdownMenuAlertDialog

Disclosure

TabsAccordion

Cards

AppCardArticleCardFeatureCard

Content

CarouselSectionHeaderEmptyStateAlertProgressSeparatorRowListRow

Chrome

PortalShellSidebarNavMobileNavTopBarAuthFrameColorSelectorFloatingNav

Tabs

Panels of one view behind a segmented list.

Three drafts are in review. The next one is due on Friday.

Sam left two comments on the cover layout this morning.

Reviews close automatically after seven days.

Variations

Source

<script lang="ts">
  import 'portal-bits/styles.css';
  import 'portal-bits/tokens.css';
  import type { Snippet } from 'svelte';

  let { children }: { children: Snippet } = $props();
</script>

{@render children()}
<script lang="ts">
  import TabsExample from './TabsExample.svelte';
</script>

<TabsExample disabled={false} />
<script lang="ts">
  import { Tabs } from 'portal-bits';
  let { disabled = false }: { disabled?: boolean } = $props();
  let current = $state('overview');
</script>

{#snippet overview()}
  <p>Three drafts are in review. The next one is due on Friday.</p>
{/snippet}
{#snippet activity()}
  <p>Sam left two comments on the cover layout this morning.</p>
{/snippet}
{#snippet settings()}
  <p>Reviews close automatically after seven days.</p>
{/snippet}

<div class="frame">
  <Tabs
    label="Project sections"
    bind:value={current}
    items={[
      { value: 'overview', label: 'Overview', content: overview },
      { value: 'activity', label: 'Activity', content: activity },
      { value: 'settings', label: 'Settings', content: settings, disabled },
    ]}
  />
</div>

<style>
  .frame {
    width: 420px;
    max-width: 100%;
  }
  p {
    margin: 0;
    color: var(--portal-muted);
  }
</style>

API reference

These tables list the props and snippets that Tabs declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.

Props

NameTypeDefaultRequiredBindingDescription
labelstringNoneYesOne-wayNames the tab list.
itemsTabItem[]NoneYesOne-wayTabs as `{ value, label, content, disabled? }`. `content` is a Snippet for the panel.
valuestringFirst enabled itemNoBindableThe selected tab.
activationMode'automatic' | 'manual'automaticNoOne-wayAutomatic selects on arrow keys. Manual waits for Enter or Space.
classstring""NoOne-wayExtra classes, added after the component classes.

Forwarded attributes

None. Tabs forwards no attributes.

The primitive underneath is a Bits UI peer dependency. Its own options are documented in the Bits UI Tabs documentation. Only the props listed on this page are part of the Tabs contract. No data attributes are documented as stable.

Limits

  • The list reuses the measured segmented track. Using it for tabs is an adaptation.
  • Horizontal only. Inactive panels stay mounted and hidden, so their state survives a switch.

Related

  • ToggleGroup
  • Accordion
Previous AlertDialog Next Accordion

On this page

  • Preview
  • Source
  • API reference
  • Props
  • Forwarded attributes
  • Limits