FleetbaseFleetbase

Tabs

<Tabs> is the lightweight tab container that yields a curried <Tab> subcomponent. Each <Tab> takes a @title and renders its body via Ember Wormhole into the shared content area.

<Tabs>

<Tabs> is the lightweight tab container in @fleetbase/ember-ui. It yields a curried <Tab> subcomponent — each Tab has a @title and yields its body content into the shared tab-content area.

For a richer, route-aware tab strip with icons, badges, closable tabs, and an Add-tab button, use <TabNavigation>.

Basic Usage

<Tabs as |Tab|>
  <Tab @title="Profile">
    <p>Profile content</p>
  </Tab>
  <Tab @title="Security">
    <p>Security content</p>
  </Tab>
  <Tab @title="Notifications">
    <p>Notifications content</p>
  </Tab>
</Tabs>

The first Tab is automatically activated. Click any tab to switch.

Arguments

<Tabs> Container

ArgumentTypeDescription
@onClick(tabName)Called when the user clicks a tab
@onTabClick(tabName)Alias of @onClick
@onTabCreated(tabName)Called when each Tab is registered (once per tab on first render)
@tagContentClassstringExtra classes on the shared content container

<Tab> Yielded Subcomponent

ArgumentTypeDescription
@titlestringThe tab label (also used as the internal tab name — dasherized)
@tabClassstringExtra classes on the tab <a>
@tabListItemClassstringExtra classes on the tab <li>
@tagPaneClassstringExtra classes on the tab pane

Any additional ...attributes on a <Tab> are forwarded to the tab pane element.

How It Works

<Tabs> renders a <ul> of tab links plus an empty <div> content area. Each <Tab> registers itself with the parent on creation and (when active) uses <EmberWormhole> to render its body into the shared content area.

The active tab is tracked on the parent. Clicking a tab updates the active state and re-portals the body.

Real-World Examples

{{!-- Settings panel with three tabs --}}
<Tabs as |Tab|>
  <Tab @title="General">
    <InputGroup @name="Display name" @value={{this.user.display_name}} />
    <InputGroup @name="Email" @value={{this.user.email}} />
  </Tab>
  <Tab @title="Security">
    <InputGroup @name="Current password" @type="password" />
    <InputGroup @name="New password" @type="password" />
  </Tab>
  <Tab @title="API">
    <ClickToReveal @value={{this.user.api_token}} @clickToCopy={{true}} />
  </Tab>
</Tabs>

{{!-- With a callback when the user switches tabs --}}
<Tabs @onTabClick={{this.recordTabSwitch}} as |Tab|>
  <Tab @title="Overview"><OverviewPanel /></Tab>
  <Tab @title="Activity"><ActivityLog @subjectId={{this.id}} /></Tab>
</Tabs>

When to Use What

NeedUse
Simple, inline tabs in a panel<Tabs>
Route-driven tabs (LinkTo)<TabNavigation> with route on each tab
Tabs with icons / badges / closable / Add button<TabNavigation>

See Also

Source

FileDescription
addon/components/tabs.hbsContainer template
addon/components/tabs.jsContainer class
addon/components/tabs/tab.hbsTab subcomponent template
addon/components/tabs/tab.jsTab subcomponent class
Tabs | Fleetbase