Tab
A navigation component that allows users to switch between different views or functional aspects of an application.
When To Use
- Tabs make it easy to switch between different views.
- Use Normal (Line) Tabs for functional aspects of a page.
- Use Enclosed Tabs for managing views within a specific container or card.
- Use Button/Pill Tabs for secondary or segmented controls.
astro
<Tabs orientation='horizontal'>
<Tab id='tab-line-1' label='Overview' active={true} variant='line' />
<Tab id='tab-line-2' label='Integrations' variant='line' />
<Tab id='tab-line-3' label='Settings' variant='line' />
</Tabs> astro
<Tabs>
<Tab label='Music' active={true} variant='button' />
<Tab label='Podcasts' variant='button' />
<Tab label='Live' variant='button' />
</Tabs>
<Tabs>
<Tab label='All' active={true} variant='pill' />
<Tab label='Unread' variant='pill' />
<Tab label='Mentions' variant='pill' />
</Tabs> astro
<Tabs orientation='horizontal'>
<Tab label='Account' active={true} variant='enclosed' />
<Tab label='Password' variant='enclosed' />
<Tab label='Team' variant='enclosed' />
</Tabs> astro
<Tabs orientation='horizontal'>
<Tab label='Messages' iconLeft='Mail' active={true} />
<Tab label='Alerts' iconRight='Bell' />
</Tabs>
<Tabs>
<Tab label='Home' icon='House' variant='icon' active={true} />
<Tab label='Search' icon='Search' variant='icon' />
<Tab label='Profile' icon='User' variant='icon' />
</Tabs> astro
<Tabs orientation='horizontal'>
<Tab label='main.js' active={true} variant='enclosed' closable />
<Tab label='style.css' variant='enclosed' closable />
<Tab label='index.html' variant='enclosed' closable />
</Tabs> This is content for Tab One.
astro
<Tabs orientation="horizontal">
<Tab label="Tab One" active={true} controls="panel1" />
<Tab label="Tab Two" controls="panel2" />
</Tabs>
<div id="panel1">This is content for Tab One.</div>
<div id="panel2" hidden style="display: none;">This is content for Tab Two.</div> astro
<Tabs orientation="horizontal">
<Tab label="Account" active={true} />
<Tab label="Password" />
<Tab label="Team" />
</Tabs> astro
<Tabs orientation='vertical' class='w-48'>
<Tab label='General' active={true} class='w-full justify-start border-l-2 border-b-0 -ml-0.5' />
<Tab label='Security' class='w-full justify-start border-l-2 border-b-0 border-transparent -ml-0.5' />
<Tab label='Billing' class='w-full justify-start border-l-2 border-b-0 border-transparent -ml-0.5' />
</Tabs> astro
<Tabs orientation="horizontal">
<Tab label="Active Users" active={true} />
<Tab label="Archived" />
<Button slot="extra" variant="primary" size="sm">
Add User
</Button>
</Tabs> API Reference
Tab
| Property | Description | Type | Default |
|---|---|---|---|
| variant | The visual style variant of the Tab. | 'line' | 'icon' | 'selector' | 'button' | 'pill' | 'enclosed' | 'line' |
| label | The text label displayed on the Tab. | string | '-' |
| icon | The Lucide icon name to display instead of a label (for icon variant). | IconName | '-' |
| iconLeft | The Lucide icon name to display to the left of the label. | IconName | '-' |
| iconRight | The Lucide icon name to display to the right of the label. | IconName | '-' |
| active | Whether the Tab is currently selected. | boolean | false |
| closable | Whether to render a close button on the Tab. | boolean | false |
| controls | The ID of the panel element this Tab controls (for ARIA). | string | '-' |
| disabled | Disables the Tab and prevents interaction. | boolean | false |
Tabs
| Property | Description | Type | Default |
|---|---|---|---|
| orientation | The layout orientation of the Tabs. | 'horizontal' | 'vertical' | 'none' | 'none' |