Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
<app-toggle-group> └── <button appToggleGroupItem>
Examples
Custom
Loading...
Default
Loading...
Disabled
Loading...
Orientation
Loading...
Sizes
Loading...
Spacing
Loading...
Variants
Loading...
API Reference
<app-toggle-group>
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
id | string | undefined | generated | Unique identifier used to create the toggle-group part IDs. |
ids | ToggleGroupElementIds | undefined | — | Overrides the generated IDs for individual parts. |
value | string[] | undefined | — | Selected values when controlled. Supports Angular two-way binding. |
defaultValue | string[] | undefined | [] | Initial selected values when uncontrolled. |
disabled | boolean | false | Disables every item in the group. |
loopFocus | boolean | true | Wraps keyboard focus from the last item to the first. |
rovingFocus | boolean | true | Manages a single tab stop across enabled items. |
multiple | boolean | false | Allows more than one item to be selected. |
deselectable | boolean | true | Allows a selected item to be toggled off. |
orientation | ToggleGroupOrientation | undefined | "horizontal" | Sets the layout and keyboard navigation axis. |
variant | "default" | "outline" | "default" | Sets the visual treatment inherited by items. |
size | "default" | "sm" | "lg" | "default" | Sets the size inherited by items. |
spacing | number | 2 | Sets the gap CSS variable and spacing data attribute. |
Use [(value)]="value" for two-way binding, or combine [value] with (valueChange) when using
signals.
Outputs
| Output | Type | Description |
|---|---|---|
valueChange | string[] | undefined | Emits the current selected values. |
valueDetailsChange | ToggleGroupValueChangeDetails | Emits details whenever selected values change. |
<button appToggleGroupItem>
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
value | string | required | Value represented by this toggle item. |
disabled | boolean | false | Disables interaction with this item. |
variant | "default" | "outline" | "default" | Visual treatment used when no parent group is present. |
size | "default" | "sm" | "lg" | "default" | Size used when no parent group is present. |
Inside <app-toggle-group>, each item inherits the group's variant, size, and spacing.
Context, Providers, and Utilities
| Export | Angular API |
|---|---|
ToggleGroupRootProvider | Directive that provides an externally created group API through value. |
ToggleGroupContext | Structural directive [toggle-group-context] exposing the root API. |
useToggleGroup(options) | Creates the signal-backed toggle-group machine inside an injection context. |
injectToggleGroupContext() | Injects the nearest toggle-group root context. |
ToggleGroupImports | Readonly collection containing the toggle-group UI and context helpers. |
Types
| Export | Description |
|---|---|
ToggleGroupApi | Connected toggle-group state and actions. |
ToggleGroupElementIds | Overrides for generated toggle-group part IDs. |
ToggleGroupItemProps | Props used to derive the state of a toggle-group item. |
ToggleGroupItemState | Derived state for a toggle-group item. |
ToggleGroupOrientation | Supported layout and keyboard navigation orientations. |
ToggleGroupValueChangeDetails | Details emitted by valueDetailsChange. |
UseToggleGroupOptions | Options accepted by useToggleGroup. |
UseToggleGroupProps | Root props accepted by the toggle-group machine. |
UseToggleGroupReturn | Signal-backed toggle-group machine returned by useToggleGroup. |
Angular
React
Solid
Svelte
Vue