Toggle Group & Tabs
Toggles, grupos de toggles e abas com foco itinerante e em qualquer orientação.
Angular: disponível Vue: disponível React: disponível React Native: disponível
Uso
<div class="demo-stack">
<div class="demo-row">
<!-- type="single": the group presses the item whose value matches [(value)] -->
<div soneToggleGroup variant="outline" type="single" [(value)]="view" aria-label="View">
@for (v of ['List', 'Board', 'Calendar']; track v) {
<button soneToggleGroupItem type="button" [value]="v">{{ v }}</button>
}
</div>
<button soneToggle variant="outline" type="button" [pressed]="pinned()" (click)="pinned.set(!pinned())">
<sone-icon icon="star" inline="start" /> Pinned
</button>
<button soneToggle type="button" aria-label="Lock editing" [pressed]="locked()" (click)="locked.set(!locked())">
<sone-icon icon="lock" />
</button>
</div>
<div style="display: grid; gap: var(--space-3)">
<div soneTabsList role="tablist" aria-label="Project">
@for (t of ['Overview', 'Activity', 'Settings']; track t) {
<button soneTabsTrigger role="tab" type="button" [id]="'demo-tab-' + t"
[active]="tab() === t" [attr.tabindex]="tab() === t ? 0 : -1" (click)="tab.set(t)">{{ t }}</button>
}
</div>
<div role="tabpanel" [attr.aria-labelledby]="'demo-tab-' + tab()" style="color: var(--text-secondary)">
{{ tab() }} content goes here.
</div>
</div>
<!-- dashed: the off state reads as "still to pick"; stretch: equal-width items and tabs -->
<div style="display: grid; gap: var(--space-3); max-width: 24rem">
<div soneToggleGroup variant="dashed" size="sm" spacing="2" stretch role="group" aria-label="Destination">
@for (d of ['Existing folder', 'New folder']; track d) {
<button soneToggleGroupItem type="button" [pressed]="dest() === d" (click)="dest.set(d)">{{ d }}</button>
}
</div>
<div soneTabsList stretch aria-label="Kind">
@for (k of ['Folder', 'Workspace']; track k) {
<button soneTabsTrigger type="button" [active]="kind() === k" (click)="kind.set(k)">{{ k }}</button>
}
</div>
</div>
</div>Importação
import {
SoneTabsListDirective,
SoneTabsTriggerDirective,
SoneToggleDirective,
SoneToggleGroupDirective,
SoneToggleGroupItemDirective,
} from "@surface-one/angular/toggle-group";Referência da API
SoneTabsListDirectiveDiretiva
| Nome | Tipo | Padrão |
|---|---|---|
variant | TabsVariant | "default" |
orientation | ToggleOrientation | "horizontal" |
stretchFill the container's width, every trigger an equal share. | boolean | false |
SoneTabsTriggerDirectiveDiretiva
| Nome | Tipo | Padrão |
|---|---|---|
active | boolean | false |
icon | boolean | false |
SoneToggleDirectiveDiretiva
| Nome | Tipo | Padrão |
|---|---|---|
variant | ToggleVariant | "default" |
size | ToggleSize | "default" |
pressed | boolean | false |
SoneToggleGroupDirectiveDiretiva
`[soneToggleGroup]` — a set of toggle buttons; arrow keys move between them. Without `type`, each item takes its own `pressed`. With `type="single"` or `"multiple"` the group presses the items that carry a `value`, two-way through `[(value)]`, and becomes one Tab stop (roving tabindex: the last focused item, else the first pressed one); items keep `aria-pressed`.
| Nome | Tipo | Padrão |
|---|---|---|
variant | ToggleVariant | "default" |
size | ToggleSize | "default" |
spacing | number | 0 |
orientation | ToggleOrientation | "horizontal" |
stretchFill the container's width on one row, every item an equal share. | boolean | false |
typeThe group presses its items (`single` / `multiple`); unset, each item's `pressed` decides. | ToggleGroupType | null | null |
valuebidirecionalThe pressed value (`single`, `null` for none) or values (`multiple`), two-way. | ToggleGroupValue | null |
disabledEvery item disabled. | boolean | false |
SoneToggleGroupItemDirectiveDiretiva
`[soneToggleGroupItem]` — takes its variant, size and (with a `value` in a typed group) pressed state from the group.
| Nome | Tipo | Padrão |
|---|---|---|
pressed | boolean | false |
valueIts value in a group with `type`: the group presses it. | string | null | null |
disabled | boolean | false |