--- title: Tab summary: Tabs switch between related views in the same place on the page. They can hold icons, a dropdown or fill the full width. description: Split content into tabs so users can switch between related views in the same context. Add icons or style the tabs as pills. related: [/ui/layout/navs-tabs] source: core/scss/ui/_nav.scss css-vars: nav-tabs sass-vars: nav classnames: component: - class: nav-tabs desc: Applied with nav, styles the triggers as tabs part: - class: nav-link desc: One tab trigger; needs role="tab" and aria-controls - class: tab-content desc: Wrapper around the panels - class: tab-pane desc: One panel; needs role="tabpanel" style: - class: nav-underline desc: Underline marker instead of a filled tab - class: nav-bordered desc: Bordered tab style modifier: - class: nav-fill desc: Spreads the tabs across the full width --- import Example from '@components/Example.astro'; import Icon from '@ui/Icon.astro'; import CodeDocs from '@components/CodeDocs.astro'; ## Default markup The default tabs highlight the current one. Each tab trigger points at a panel, and Bootstrap shows one panel at a time.

Home tab

Cursus turpis vestibulum, dui in pharetra vulputate id sed non turpis ultricies fringilla at sed facilisis lacus pellentesque purus nibh

Profile tab

Fringilla egestas nunc quis tellus diam rhoncus ultricies tristique enim at diam, sem nunc amet, pellentesque id egestas velit sed
## Tabs with icons An [icon](/ui/components/icon) in the tab label makes tabs easier to tell apart when the labels are similar.

Home tab

Cursus turpis vestibulum, dui in pharetra vulputate id sed non turpis ultricies fringilla at sed facilisis lacus pellentesque purus nibh

Profile tab

Fringilla egestas nunc quis tellus diam rhoncus ultricies tristique enim at diam, sem nunc amet, pellentesque id egestas velit sed

Settings tab

Donec ac vitae diam amet vel leo egestas consequat rhoncus in luctus amet, facilisi sit mauris accumsan nibh habitant senectus
## Tabs only with icons Tabs with only an icon save space. Give each one an `aria-label`, because there's no text to read.

Home tab

Cursus turpis vestibulum, dui in pharetra vulputate id sed non turpis ultricies fringilla at sed facilisis lacus pellentesque purus nibh

Profile tab

Fringilla egestas nunc quis tellus diam rhoncus ultricies tristique enim at diam, sem nunc amet, pellentesque id egestas velit sed

Settings tab

Donec ac vitae diam amet vel leo egestas consequat rhoncus in luctus amet, facilisi sit mauris accumsan nibh habitant senectus
## Tabs with dropdown A tab can open a [dropdown](/ui/components/dropdown) with more views, so a long row of tabs stays short.

Home tab

Cursus turpis vestibulum, dui in pharetra vulputate id sed non turpis ultricies fringilla at sed facilisis lacus pellentesque purus nibh

Profile tab

Fringilla egestas nunc quis tellus diam rhoncus ultricies tristique enim at diam, sem nunc amet, pellentesque id egestas velit sed
## Full-width tabs Add the `.nav-fill` class to make the tabs take up the full space of the parent element.

Home tab

Cursus turpis vestibulum, dui in pharetra vulputate id sed non turpis ultricies fringilla at sed facilisis lacus pellentesque purus nibh

Profile tab

Fringilla egestas nunc quis tellus diam rhoncus ultricies tristique enim at diam, sem nunc amet, pellentesque id egestas velit sed

Activity tab

Donec ac vitae diam amet vel leo egestas consequat rhoncus in luctus amet, facilisi sit mauris accumsan nibh habitant senectus
## JavaScript Tabler activates the tab that matches the URL hash on page load, so you can link to a specific tab. This is the code that runs: ## Accessibility - Wrap the tabs in an element with `role="tablist"`, give each trigger `role="tab"` and each panel `role="tabpanel"`, and link them with `aria-controls` and `aria-labelledby`. - Bootstrap sets `aria-selected` and moves focus with the arrow keys, but only when the roles above are present. Without them the tabs are plain links. - Tabler activates a tab from the url hash on page load, so a tab trigger with `href="#billing"` doubles as a deep link. Keep the panel ids stable if you link to them. - Only the active panel should be reachable. Bootstrap hides the others with `display: none`, which also removes them from the tab order.