Skip to content

Tabs

A tab bar that switches between panes already in the page, with the Bootstrap JavaScript bundled in tabler.js.

items is an array of {label, id?, icon?, active?, text?, disabled?}. Tabs renders the bar, with a Tabs:Item for each entry, then a Tabs:Content holding a Tabs:Pane with the text of each entry. Each pane gets the id <id>-<n>, starting at 1, unless the entry has its own id. Without an id, the panes get a random prefix (tabs-<n>), and the bar no id: set your own when the ids must stay the same between renders, for example to link to a tab. The first tab is active; once an entry sets active, only the entries with active: true are.

icon puts a Tabler icon, or a UX Icons name (lucide:house), before the label, in a .nav-link-icon. disabled makes a tab non-interactive.

Tabs renders the bar, Tabs:Content the panes. Each Tabs:Item targets the id of a Tabs:Pane, without the #. Mark the first tab and its pane active.

With items, override the panes block to write the panes yourself, for example to put markup in them or a class on Tabs:Content, and keep the generated bar. Give the panes the ids the bar targets.

  • Tabs: switches between panes in the page, without loading a new page.
  • Nav: static navigation, each item links to a URL. Use it when each tab is its own page.
  • Navbar: the header or sidebar of the app.

pills swaps the tabs for pills:

underline swaps the tabs for underlined links. bordered draws a border under the whole bar and underlines the active tab. fill makes the tabs share the full width. The panes are left out of this example:

pills wins over underline when both are set. bordered and fill combine with any style.

card fits the tab bar in a card header. Put the panes in the card body:

Tabs:

Prop Type Default Description
id string? null DOM id of the bar and prefix of the generated pane ids; random prefix when null
items array? null {label, id?, icon?, active?, text?, disabled?} entries, rendered with Tabs:Item and Tabs:Pane
pills bool false Pills (nav-pills) instead of tabs (nav-tabs)
underline bool false Underlined links (nav-underline) instead of tabs; ignored with pills
bordered bool false Border under the whole bar, active tab underlined (nav-bordered)
fill bool false Tabs share the full width (nav-fill)
card bool false Tab bar for a card header (card-header-tabs)

Other attributes go to the root <ul class="nav" role="tablist">, not to the panes.

Tabs:Item:

Prop Type Default Description
target string (required) id of the pane it shows, without #
active bool false The tab selected first
disabled bool false Non-interactive tab (disabled, with aria-disabled="true")
icon string? null Leading Tabler icon or UX Icons name (nav-link-icon)

Other attributes go to the <a class="nav-link" data-bs-toggle="tab">, not to the <li>.

Tabs:Pane:

Prop Type Default Description
id string (required) DOM id, matching the target of its Tabs:Item
active bool false The pane shown first (active show)

Other attributes go to the <div class="tab-pane">. Tabs:Content has no props: attributes go to its <div class="tab-content">.

Component Renders
Tabs:Item <li class="nav-item"> around an <a href="#target" data-bs-toggle="tab">
Tabs:Content <div class="tab-content">, the container of the panes
Tabs:Pane <div class="tab-pane" role="tabpanel">, one pane
Block Default
content A Tabs:Item for each entry of the items prop
panes After the bar: Tabs:Content with a Tabs:Pane holding the text of each entry, when items is set

The content of Tabs:Item is its label, after the icon; the content of Tabs:Pane is the pane.