Sizes and tab states
size: xsm
Profile.
Billing.
Audit.
size: sm
Profile.
Billing.
Audit.
size: md
Profile.
Billing.
Audit.
size: lg
Profile.
Billing.
Audit.
size: slg
Profile.
Billing.
Audit.
gog-tabs / gog-tab
A tablist over projected <gog-tab> children. Each tab declares its own header text, icon and disabled state, so a tab is defined in exactly one place rather than split between a header array and a content block.
Import both components and nest them.
import { TabComponent, TabsComponent } from '@guildofgleks/ui';
@Component({
// ...
imports: [TabsComponent, TabComponent],
})
activeIndex is two-way and gogTabChange reports each change. A disabled tab is skipped by the arrow keys and cannot be chosen.
Profile content.
Billing content.
Not available.
Team content.
activeIndex: 0 · gogTabChange: none yet
<gog-tabs ariaLabel="Account" [(activeIndex)]="activeIndex" (gogTabChange)="lastChange.set($event)">
<gog-tab label="Profile"><p>Profile content.</p></gog-tab>
<gog-tab label="Billing"><p>Billing content.</p></gog-tab>
<gog-tab label="Audit" disabled><p>Not available.</p></gog-tab>
<gog-tab label="Team"><p>Team content.</p></gog-tab>
</gog-tabs>
<p>activeIndex: {{ activeIndex() }} · gogTabChange: {{ lastChange() ?? 'none yet' }}</p> A tab is active, inactive or disabled; every tablist here holds one of each. A tab is disabled through its own disabled input. Hover, focus and press are pseudo-class states a page cannot force; the headers are live.
size: xsm
Profile.
Billing.
Audit.
size: sm
Profile.
Billing.
Audit.
size: md
Profile.
Billing.
Audit.
size: lg
Profile.
Billing.
Audit.
size: slg
Profile.
Billing.
Audit.
<!-- Each tablist holds an active tab, an inactive one and a disabled one. -->
@for (size of sizes; track size) {
<p>size: {{ size }}</p>
<gog-tabs [size]="size" ariaLabel="Account">
<gog-tab label="Profile"><p>Profile.</p></gog-tab>
<gog-tab label="Billing"><p>Billing.</p></gog-tab>
<gog-tab label="Audit" disabled><p>Audit.</p></gog-tab>
</gog-tabs>
} Where the headers sit in the row. stretch shares the row between them; the other three keep each header its natural width.
align: start
Profile.
Billing.
Audit.
align: center
Profile.
Billing.
Audit.
align: end
Profile.
Billing.
Audit.
align: stretch
Profile.
Billing.
Audit.
@for (align of aligns; track align) {
<p>align: {{ align }}</p>
<gog-tabs [align]="align" size="sm" ariaLabel="Account">
<gog-tab label="Profile"><p>Profile.</p></gog-tab>
<gog-tab label="Billing"><p>Billing.</p></gog-tab>
<gog-tab label="Audit" disabled><p>Audit.</p></gog-tab>
</gog-tabs>
}iconName on a gog-tab adds a leading icon to the default header. It is aria-hidden: the label names the tab.
Inbox.
Starred.
Archive.
<gog-tabs ariaLabel="Mailbox">
<gog-tab label="Inbox" iconName="mail"><p>Inbox.</p></gog-tab>
<gog-tab label="Starred" iconName="star"><p>Starred.</p></gog-tab>
<gog-tab label="Archive" iconName="download"><p>Archive.</p></gog-tab>
</gog-tabs> A gogTabHeader template replaces every header button's content, with the gog-tab itself as $implicit and active, disabled and index beside it. It renders inside the tab's button, so it must not hold another control.
Twelve unread.
Sent.
<gog-tabs ariaLabel="Mailbox">
<!-- One template for every header. It renders inside the tab's button: markup only. -->
<ng-template gogTabHeader let-tab let-active="active">
{{ tab.label() }}
@if (tab.label() === 'Inbox') {
<gog-tag size="xsm" [variant]="active ? 'info' : 'warning'">12</gog-tag>
}
</ng-template>
<gog-tab label="Inbox"><p>Twelve unread.</p></gog-tab>
<gog-tab label="Sent"><p>Sent.</p></gog-tab>
</gog-tabs>The headers stack beside the panel, and ArrowUp / ArrowDown move between them instead of left and right.
General settings.
Security settings.
Billing settings.
<gog-tabs orientation="vertical" ariaLabel="Settings">
<gog-tab label="General"><p>General settings.</p></gog-tab>
<gog-tab label="Security"><p>Security settings.</p></gog-tab>
<gog-tab label="Billing"><p>Billing settings.</p></gog-tab>
</gog-tabs> Headers that do not fit scroll inside a gog-scroll rather than a native scrollbar — the one piece of chrome no --gog-* token can reach. With scrollActiveIntoView on (the default) choosing a tab centres it — instantly on first render and under prefers-reduced-motion, smoothly otherwise — and the track is hidden. The second row turns it off and gets a track, since then it is the only hint there is more to reach; showScrollTrack sets the track explicitly.
January.
February.
March.
April.
May.
June.
July.
August.
September.
October.
November.
December.
January.
February.
March.
April.
May.
June.
July.
August.
September.
October.
November.
December.
<!-- scrollActiveIntoView on (the default): the chosen tab is centred, no track. -->
<gog-tabs size="sm" ariaLabel="Month" [activeIndex]="8">
@for (month of months; track month) {
<gog-tab [label]="month">
<p>{{ month }}.</p>
</gog-tab>
}
</gog-tabs>
<!-- Off: a track, shown while the pointer is over the row, reaches what is off-screen. -->
<gog-tabs size="sm" ariaLabel="Month" [scrollActiveIntoView]="false">
@for (month of months; track month) {
<gog-tab [label]="month">
<p>{{ month }}.</p>
</gog-tab>
}
</gog-tabs> The tablist shows the first enabled tab rather than nothing — but activeIndex keeps the value it was given, so the bound value and the tab on screen disagree. Bind indexes of enabled tabs.
Profile.
Billing.
Audit.
activeIndex: 1
<div>
<gog-button variant="outline" size="sm" (gogClick)="activeIndex.set(2)">
activeIndex = 2 (disabled)
</gog-button>
<gog-button variant="outline" size="sm" (gogClick)="activeIndex.set(1)"
>activeIndex = 1</gog-button
>
</div>
<gog-tabs ariaLabel="Account" [(activeIndex)]="activeIndex">
<gog-tab label="Profile"><p>Profile.</p></gog-tab>
<gog-tab label="Billing"><p>Billing.</p></gog-tab>
<gog-tab label="Audit" disabled><p>Audit.</p></gog-tab>
</gog-tabs>
<p>activeIndex: {{ activeIndex() }}</p> Content written directly inside a <gog-tab> renders eagerly and is merely hidden while inactive — right for cheap content, because scroll position, unsubmitted input and any state the DOM holds survive a switch. Wrap it in an <ng-template gogTabContent> and it is built on first activation and kept alive after. Which you get is decided by whether that template is present — there is no lazy input to keep in sync with it.
Type in the first tab, switch away and back: the text is still there. The third tab's content is not in the DOM until you open it.
Switch back: the draft is still there.
<gog-tabs ariaLabel="Content">
<!-- Eager: built at once, only hidden while inactive, so it keeps what was typed. -->
<gog-tab label="Eager">
<gog-inputfield label="Draft" placeholder="Type, switch away, come back" />
</gog-tab>
<gog-tab label="Another"><p>Switch back: the draft is still there.</p></gog-tab>
<!-- Lazy: built the first time its tab is shown, then kept. -->
<gog-tab label="Lazy">
<ng-template gogTabContent>
<p>Built on first activation — this was not in the DOM until now.</p>
</ng-template>
</gog-tab>
</gog-tabs> The headers form a real tablist, and each panel is a tabpanel labelled by its header.
ariaLabel on <gog-tabs> to say what the tabs switch between ("Account settings"); each tab is named by its label. Only the app knows that name, so an unnamed tablist logs one console.warn per page in dev mode orientation — a horizontal tablist leaves ArrowDown to the page — and Home / End jump to the ends. Activation follows focus, the automatic variant of the ARIA tabs pattern. Disabled tabs are skipped rather than merely unclickable. | Name | Type | Default | Description |
|---|---|---|---|
scrollActiveIntoView | boolean | true | With an overflowing header row, selecting a tab scrolls it into view — instantly on first render, smoothly afterwards (and instantly under prefers-reduced-motion). |
showScrollTrack | boolean | undefined | undefined | Whether the header row shows a scrollbar track. Unset it follows scrollActiveIntoView: hidden while that is on (the scrolling is driven for you), shown once it is off, where the track is the only hint that there is more to reach. |
activeIndex | number | 0 | Index of the visible tab. Two-way bindable with [(activeIndex)]. |
align | 'start' | 'center' | 'end' | 'stretch' | 'start' | How the headers distribute along the tablist. stretch makes them share the width. |
orientation | 'horizontal' | 'vertical' | 'horizontal' | Which way the tablist runs. |
size | 'xsm' | 'sm' | 'md' | 'lg' | 'slg' | 'md' | Header typography and padding. |
fullWidth | boolean | false | Stretches the whole component to fill its container. |
ariaLabel | string | '' | Names the tablist: what the tabs switch between ("Account settings"). Unset, it warns in dev mode (since 21.19.0). |
ripple | boolean | undefined | undefined | Press ripple on each tab header. Unset, falls back to GOG_CONFIG.ripple.enabled, which is off by default; setting it here wins over the app-wide value in both directions. |
| Name | Payload | Description |
|---|---|---|
gogTabChange | number | Emitted with the new index when the active tab changes. |
activeIndexChange | number | The activeIndex model’s change event, for [(activeIndex)]. |
| Name | Type | Default | Description |
|---|---|---|---|
label | string | '' | Header text. A tab declares its own header, so it is defined in exactly one place. |
iconName | GogIconName | null | null | Optional leading icon in the header. |
disabled | boolean | false | Makes the tab unreachable by click and skipped by arrow navigation. |
| Directive | Context | Description |
|---|---|---|
gogTabHeader | $implicit (the gog-tab), active, disabled, index | On an <ng-template> inside gog-tabs. Replaces every header button's content. |
gogTabContent | none | On an <ng-template> inside a gog-tab. Makes that tab's content lazy — built on first activation, kept alive after. |
Set any of these once with provideGogConfig() instead of repeating them on every instance — an instance's own input still wins when it sets one itself. See Global Configuration for the full reference.
GOG_CONFIG.ripple.enabledThis site is not on the default here. The library ships ripple.enabled as false; these docs set it to true app-wide so the demos above actually show the press feedback. In a fresh app you get no ripple until you ask for one — the droplet button in the header switches this site between the two, and it is on right now.
Every CSS custom property the tabs paint with. Override any of them — on a single instance, a subtree, or a theme — to restyle them. See the Theming guide for the full token-layering model, or the Theme Generator to tweak these live.
| Token | Description |
|---|---|
--gog-tabs-rest-color / -hover-color / -active-color | Tab header label, per state. |
--gog-tabs-press-bg / -press-color | A header under a press. It carries a label colour as well as a background, the way the button does, because a header has little fill of its own to deepen. |
--gog-tabs-indicator-color / -indicator-thickness / -indicator-radius | The bar marking the active tab. |
--gog-tabs-header-border-color / -header-border-width / -header-border-style | The rule under the tablist. |
--gog-tabs-{size}-font-size / -{size}-padding | Header typography and padding, per size step (sm/md/lg/slg). |
--gog-tabs-tab-gap / -gap / -icon-size | Gap between headers, between a header’s icon and its label, and icon size. |
--gog-tabs-panel-padding / -panel-color | The content panel below the tablist. |
--gog-tabs-focus-ring-color / -focus-ring-width / -focus-ring-offset / -disabled-opacity | Keyboard focus ring and the disabled state. |