Tabs provide a way to navigate between panels that display related content without leaving the page.
Tabs help organize related content into manageable sections, making it easier for users to find and focus on specific information. They're particularly useful for displaying content in compact spaces, such as within modals or cards, allowing users to switch between sections without navigating away from the current view.
<daff-tabs aria-label="Product details">
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faAlignLeft" daffPrefix></fa-icon>
Description
</daff-tab-label>
<daff-tab-panel>
A lightweight running shoe with a breathable mesh upper and responsive foam midsole built for everyday miles.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faListUl" daffPrefix></fa-icon>
Specifications
</daff-tab-label>
<daff-tab-panel>
Weight: 8.2 oz. Drop: 8mm. Upper: recycled mesh. Outsole: carbon rubber.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faTruck" daffPrefix></fa-icon>
Shipping & Returns
</daff-tab-label>
<daff-tab-panel>
Free standard shipping on orders over $50. Return any unworn item within 30 days for a full refund.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faStar" daffPrefix></fa-icon>
Reviews
</daff-tab-label>
<daff-tab-panel>
Rated 4.8 out of 5 from 1,204 verified customer reviews.
</daff-tab-panel>
</daff-tab>
</daff-tabs>
When to use
When not to use
Import DAFF_TABS_COMPONENTS into your component:
import { DAFF_TABS_COMPONENTS } from '@daffodil/design/tabs';
@Component({
selector: 'custom-component',
templateUrl: './custom-component.component.html',
imports: [
DAFF_TABS_COMPONENTS,
],
})
export class CustomComponent {}
A tabs component is composed of a container, tabs, labels, and panels:
<daff-tabs>
<daff-tab>
<daff-tab-label>
<fa-icon daffPrefix></fa-icon>
Tab Label
<fa-icon daffSuffix></fa-icon>
</daff-tab-label>
<daff-tab-panel>
Tab content goes here
</daff-tab-panel>
</daff-tab>
</daff-tabs>
<daff-tabs>: The wrapper component that contains all tabs.<daff-tab>: A single tab that groups a label and its corresponding panel together.<daff-tab-label>: The clickable label that activates its corresponding tab panel. Labels can contain text, icons, or both.<daff-tab-panel>: The content area displayed when a tab is active.[daffPrefix] or [daffSuffix] directive to an icon to place it before or after the label text. This provides a quick visual cue about the tab's purpose.Set linkMode to true to replace the tab buttons with anchors, connecting the selected tab to a URL.
By default, the current URL and tab query param are used. Override these with the url and queryParam inputs, respectively.
<daff-tabs aria-label="Product details" [linkMode]="true">
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faAlignLeft" daffPrefix></fa-icon>
Description
</daff-tab-label>
<daff-tab-panel>
A lightweight running shoe with a breathable mesh upper and responsive foam midsole built for everyday miles.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faListUl" daffPrefix></fa-icon>
Specifications
</daff-tab-label>
<daff-tab-panel>
Weight: 8.2 oz. Drop: 8mm. Upper: recycled mesh. Outsole: carbon rubber.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faTruck" daffPrefix></fa-icon>
Shipping & Returns
</daff-tab-label>
<daff-tab-panel>
Free standard shipping on orders over $50. Return any unworn item within 30 days for a full refund.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faStar" daffPrefix></fa-icon>
Reviews
</daff-tab-label>
<daff-tab-panel>
Rated 4.8 out of 5 from 1,204 verified customer reviews.
</daff-tab-panel>
</daff-tab>
</daff-tabs>
Set the initiallySelected input to a tab's id to select that tab on load. Without it, the first tab is selected by default.
<daff-tabs aria-label="Product details" [initiallySelected]="'reviews'">
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faAlignLeft" daffPrefix></fa-icon>
Description
</daff-tab-label>
<daff-tab-panel>
A lightweight running shoe with a breathable mesh upper and responsive foam midsole built for everyday miles.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faListUl" daffPrefix></fa-icon>
Specifications
</daff-tab-label>
<daff-tab-panel>
Weight: 8.2 oz. Drop: 8mm. Upper: recycled mesh. Outsole: carbon rubber.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faTruck" daffPrefix></fa-icon>
Shipping & Returns
</daff-tab-label>
<daff-tab-panel>
Free standard shipping on orders over $50. Return any unworn item within 30 days for a full refund.
</daff-tab-panel>
</daff-tab>
<daff-tab id="reviews">
<daff-tab-label>
<fa-icon [icon]="faStar" daffPrefix></fa-icon>
Reviews
</daff-tab-label>
<daff-tab-panel>
Rated 4.8 out of 5 from 1,204 verified customer reviews.
</daff-tab-panel>
</daff-tab>
</daff-tabs>
Set the disabled property on a <daff-tab> to make it non-interactive.
<daff-tabs aria-label="Product details">
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faAlignLeft" daffPrefix></fa-icon>
Description
</daff-tab-label>
<daff-tab-panel>
A lightweight running shoe with a breathable mesh upper and responsive foam midsole built for everyday miles.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faListUl" daffPrefix></fa-icon>
Specifications
</daff-tab-label>
<daff-tab-panel>
Weight: 8.2 oz. Drop: 8mm. Upper: recycled mesh. Outsole: carbon rubber.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faTruck" daffPrefix></fa-icon>
Shipping & Returns
</daff-tab-label>
<daff-tab-panel>
Free standard shipping on orders over $50. Return any unworn item within 30 days for a full refund.
</daff-tab-panel>
</daff-tab>
<daff-tab [disabled]="true">
<daff-tab-label>
<fa-icon [icon]="faStar" daffPrefix></fa-icon>
Reviews
</daff-tab-label>
<daff-tab-panel>
Rated 4.8 out of 5 from 1,204 verified customer reviews.
</daff-tab-panel>
</daff-tab>
</daff-tabs>
Call the select method with a tab's id to change the active tab from your own code.
<div class="custom-select-tabs__buttons">
<button daff-button size="sm" (click)="selectShipping()">
View shipping info
</button>
<button daff-button size="sm" (click)="selectReviews()">
Read reviews
</button>
</div>
<daff-tabs aria-label="Product details">
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faAlignLeft" daffPrefix></fa-icon>
Description
</daff-tab-label>
<daff-tab-panel>
A lightweight running shoe with a breathable mesh upper and responsive foam midsole built for everyday miles.
</daff-tab-panel>
</daff-tab>
<daff-tab>
<daff-tab-label>
<fa-icon [icon]="faListUl" daffPrefix></fa-icon>
Specifications
</daff-tab-label>
<daff-tab-panel>
Weight: 8.2 oz. Drop: 8mm. Upper: recycled mesh. Outsole: carbon rubber.
</daff-tab-panel>
</daff-tab>
<daff-tab id="shipping">
<daff-tab-label>
<fa-icon [icon]="faTruck" daffPrefix></fa-icon>
Shipping & Returns
</daff-tab-label>
<daff-tab-panel>
Free standard shipping on orders over $50. Return any unworn item within 30 days for a full refund.
</daff-tab-panel>
</daff-tab>
<daff-tab id="reviews">
<daff-tab-label>
<fa-icon [icon]="faStar" daffPrefix></fa-icon>
Reviews
</daff-tab-label>
<daff-tab-panel>
Rated 4.8 out of 5 from 1,204 verified customer reviews.
</daff-tab-panel>
</daff-tab>
</daff-tabs>
Tabs follow the Tabs WAI-ARIA design pattern.
role="tablist", role="tab", and role="tabpanel" on the appropriate elementsid attribute)aria-labelledby linking tab panels to their corresponding tab labelsaria-selected indicating the active tabaria-label on <daff-tabs> to describe the tab group<daff-tabs aria-label="Product information">
<daff-tab>
<daff-tab-label>Description</daff-tab-label>
<daff-tab-panel>Product description content</daff-tab-panel>
</daff-tab>
</daff-tabs>
| Key | Action |
|---|---|
Left Arrow |
Moves focus and activates the previous tab. If focus is on the first tab, focus moves to the last tab. |
Right Arrow |
Moves focus and activates the next tab. If focus is on the last tab, focus moves to the first tab. |
Home |
Moves focus and activates the first tab. |
End |
Moves focus and activates the last tab. |