Tabs
import {TabsModule} from "@qualcomm-ui/angular/tabs"Examples
Horizontal
The default orientation is horizontal. The left and right arrow keys can be used to navigate between tabs.
<div defaultValue="documents" q-tabs-root>
<div q-tabs-list>
<div q-tabs-indicator></div>
<div q-tab-root value="documents">
<button q-tab-button>Documents</button>
</div>
<div q-tab-root value="products">
<button q-tab-button>Products</button>
</div>
<div q-tab-root value="software">
<button q-tab-button>Software</button>
</div>
<div q-tab-root value="hardware">
<button q-tab-button>Hardware</button>
</div>
</div>
<div q-tabs-panel value="documents">Documents</div>
<div q-tabs-panel value="products">Products</div>
<div q-tabs-panel value="software">Software</div>
<div q-tabs-panel value="hardware">Hardware</div>
</div>Vertical
In vertical orientation, the up and down arrow keys are used instead.
<div
class="w-full"
defaultValue="documents"
orientation="vertical"
q-tabs-root
>
<div q-tabs-list>
<div q-tabs-indicator></div>
<div q-tab-root value="documents">
<button q-tab-button>Documents</button>
</div>
<div q-tab-root value="products">
<button q-tab-button>Products</button>
</div>
<div q-tab-root value="software">
<button q-tab-button>Software</button>
</div>
<div q-tab-root value="hardware">
<button q-tab-button>Hardware</button>
</div>
</div>
<div q-tabs-panel value="documents">Documents</div>
<div q-tabs-panel value="products">Products</div>
<div q-tabs-panel value="software">Software</div>
<div q-tabs-panel value="hardware">Hardware</div>
</div>Icons and variants
Tabs support start and end icons. Customize the variant with the iconVariant prop. Use the variant prop to change the appearance of the tab.
Controlled Value
The tab's active value can be controlled via the value, onValueChange, and defaultValue properties. These props follow our controlled state pattern.
Sizes
Line
The line variant supports four sizes: sm, md, lg, and xl
Contained
The contained variant supports only two sizes: sm and md
@for (size of sizes; track size) {
<div
defaultValue="documents"
q-tabs-root
variant="contained"
[size]="size"
>
<div q-tabs-list>
<div q-tab-root value="documents">
<button q-tab-button>Documents</button>
</div>
<div q-tab-root value="products">
<button q-tab-button>Products</button>
</div>
<div q-tab-root value="software">
<button q-tab-button>Software</button>
</div>
<div q-tab-root value="hardware">
<button q-tab-button>Hardware</button>
</div>
</div>
</div>
}Disabled
Disable specific tabs with the disabled prop on the <Tab.Root> component.
URL Search Parameters
The following example demonstrates how to render tabs that sync with the Angular router's query parameters.
Context
Use the tabsContext structural directive to access the tabs API from the template.
<ng-container *tabsContext="let tabsApi">
<div q-tabs-panel value="tab-1">
<button
endIcon="ChevronRight"
q-button
size="sm"
variant="outline"
(click)="tabsApi.setValue('tab-2')"
>
Go to next tab
</button>
</div>
<div class="flex items-center gap-2" q-tabs-panel value="tab-2">
<button
q-button
size="sm"
startIcon="ChevronLeft"
variant="outline"
(click)="tabsApi.setValue('tab-1')"
>
Go to prev tab
</button>
<button
endIcon="ChevronRight"
q-button
size="sm"
variant="outline"
(click)="tabsApi.setValue('tab-3')"
>
Go to next tab
</button>
</div>
<div q-tabs-panel value="tab-3">
<button
q-button
size="sm"
startIcon="ChevronLeft"
variant="outline"
(click)="tabsApi.setValue('tab-2')"
>
Go to previous tab
</button>
</div>
</ng-container>
Add and Remove Tabs
API
Tabs
q-tabs-root
| Prop | Type | Default |
|---|---|---|
The activation mode of the tabs. | | 'automatic' | "automatic" |
If true, the indicator's position change will animate when the active tab
changes. Only applies to the line variant. | boolean | true |
Determines whether tabs act as a standalone composite widget (true) or as a
non-focusable component within another widget (false). | boolean | true |
The initial selected tab value when rendered.
Use when you don't need to control the selected tab value. | string | |
Whether the active tab can be deselected when clicking on it. | boolean | |
The document's text/writing direction. | 'ltr' | 'rtl' | "ltr" |
A root node to correctly resolve the Document in custom environments. i.e.,
Iframes, Electron. | () => | |
The visual style of tab icons. | | 'ghost' | 'ghost' |
When true, the component will not be rendered in the DOM until it becomes
visible or active. | boolean | false |
Whether the keyboard navigation will loop from last tab to first, and vice versa. | boolean | true |
The orientation of the tabs. Can be horizontal or vertical | | 'horizontal' | "horizontal" |
| 'sm' | 'md' | |
Specifies the localized strings that identifies the accessibility elements and
their states | { | |
When true, the component will be completely removed from the DOM when it
becomes inactive or hidden, rather than just being hidden with CSS. | boolean | false |
The controlled selected tab value | string | |
Governs the appearance of the tab. | | 'line' | |
Callback to be called when the focused tab changes | string | |
Callback to be called when the selected/active tab changes | string |
| 'automatic'
| 'manual'
booleanline variant.booleanstringboolean'ltr' | 'rtl'
() =>
| Node
| ShadowRoot
| Document
| 'ghost'
| 'filled'
booleanboolean| 'horizontal'
| 'vertical'
horizontal or vertical| 'sm'
| 'md'
| 'lg'
| 'xl'
lg
and xl are not supported by the contained variant.{
listLabel?: string
}
booleanstring| 'line'
| 'contained'
stringstring| Attribute / Property | Value |
|---|---|
class | 'qui-tabs__root' |
data-focus | |
data-orientation | | 'horizontal' |
data-part | 'root' |
data-scope | 'tabs' |
data-size | | 'sm' |
class'qui-tabs__root'data-focusdata-orientation| 'horizontal'
| 'vertical'
data-part'root'data-scope'tabs'data-size| 'sm'
| 'md'
| 'lg'
| 'xl'
q-tabs-list
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-tabs__list' |
data-focus | |
data-orientation | | 'horizontal' |
data-part | 'list' |
data-scope | 'tabs' |
data-size | | 'sm' |
data-variant | | 'line' |
class'qui-tabs__list'data-focusdata-orientation| 'horizontal'
| 'vertical'
data-part'list'data-scope'tabs'data-size| 'sm'
| 'md'
| 'lg'
| 'xl'
data-variant| 'line'
| 'contained'
q-tabs-indicator
This directive is automatically rendered by the q-tabs-list directive. It can be customized like so:
<div q-tabs-list>
<!-- customize the element here -->
<div q-tabs-indicator></div>
<!-- ... -->
</div>| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-tabs__indicator' |
data-animate | |
data-focusWhether any tab has the simulated focus state. | |
data-focus-visibleWhether any tab has the simulated focus-visible state. | |
data-orientation | | 'horizontal' |
data-part | 'indicator' |
data-scope | 'tabs' |
data-size | | 'sm' |
data-variant | | 'line' |
hiddenHidden for contained variant. | boolean |
style |
class'qui-tabs__indicator'data-animatedata-focusdata-focus-visibledata-orientation| 'horizontal'
| 'vertical'
data-part'indicator'data-scope'tabs'data-size| 'sm'
| 'md'
| 'lg'
| 'xl'
data-variant| 'line'
| 'contained'
hiddenbooleancontained variant.styleq-tabs-panel
| Prop | Type |
|---|---|
The value of the associated tab | string |
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
stringstring| Attribute / Property | Value |
|---|---|
class | 'qui-tabs__panel' |
data-orientation | | 'horizontal' |
data-ownedby | string |
data-part | 'panel' |
data-scope | 'tabs' |
data-selected | |
hidden | boolean |
tabIndex | -1 | 0 |
class'qui-tabs__panel'data-orientation| 'horizontal'
| 'vertical'
data-ownedbystringdata-part'panel'data-scope'tabs'data-selectedhiddenbooleantabIndex-1 | 0
Tab
q-tab-root
| Attribute / Property | Value |
|---|---|
class | 'qui-tab__root' |
data-orientation | | 'horizontal' |
data-part | 'tab' |
data-scope | 'tabs' |
data-size | | 'sm' |
data-variant | | 'line' |
class'qui-tab__root'data-orientation| 'horizontal'
| 'vertical'
data-part'tab'data-scope'tabs'data-size| 'sm'
| 'md'
| 'lg'
| 'xl'
data-variant| 'line'
| 'contained'
q-tab-button
| Prop | Type |
|---|---|
lucide-angular icon, positioned after the label. | | LucideIconData |
To customize the element, provide it using the directive instead:
<button q-tab-button> | |
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
lucide-angular icon, positioned before the label. | | LucideIconData |
To customize the element, provide it using the directive instead:
<button q-tab-button> | |
| LucideIconData
| string
<button q-tab-button>
<svg q-end-icon icon="..."></svg>
</button>
string| LucideIconData
| string
<button q-tab-button>
<svg q-start-icon icon="..."></svg>
</button>
| Attribute / Property | Value |
|---|---|
class | 'qui-tab__button' |
data-disabled | |
data-focus | |
data-focus-visible | |
data-indicator-rendered | |
data-orientation | | 'horizontal' |
data-ownedby | string |
data-part | 'tab-button' |
data-scope | 'tabs' |
data-selected | |
data-size | | 'sm' |
data-value | string |
data-variant | | 'line' |
tabIndex | -1 | 0 |
class'qui-tab__button'data-disableddata-focusdata-focus-visibledata-indicator-rendereddata-orientation| 'horizontal'
| 'vertical'
data-ownedbystringdata-part'tab-button'data-scope'tabs'data-selecteddata-size| 'sm'
| 'md'
| 'lg'
| 'xl'
data-valuestringdata-variant| 'line'
| 'contained'
tabIndex-1 | 0
q-tab-dismiss-button
| Prop | Type |
|---|---|
string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-tab__dismiss-button' |
data-part | 'tab-dismiss-button' |
data-scope | 'tabs' |
data-size | | 'sm' |
class'qui-tab__dismiss-button'data-part'tab-dismiss-button'data-scope'tabs'data-size| 'sm'
| 'md'
| 'lg'
| 'xl'
tabsContext
Used to access the tabs API from the template.
<div q-tabs-root>
<!-- type-aware context for the tabs API -->
<ng-container *tabsContext="let tabsApi">
<button (click)="tabsApi.setValue('...')"></button>
</ng-container>
</div>| Prop | Type |
|---|---|
Clears the value of the tabs. | () => void |
Set focus on the selected tab button | () => void |
The value of the tab that is currently focused. | string |
Returns the state of the tab with the given props | (props: { |
Sets the indicator rect to the tab with the given value | ( |
Sets the value of the tabs. | ( |
Synchronizes the tab index of the content element.
Useful when rendering tabs within a select or combobox | () => void |
The current value of the tabs. | string |
() => void
() => void
string(props: {
disabled?: boolean
value: string
}) => {
disabled: boolean
focused: boolean
selected: boolean
}
(
value: string,
) => void
(
value: string,
) => void
() => void
string