Search documentation

Search the documentation and open a page.

A set of two-state buttons that can be toggled on or off.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/toggle-group

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

InputTypeDefaultDescription
idstring | undefinedgeneratedUnique identifier used to create the toggle-group part IDs.
idsToggleGroupElementIds | undefined—Overrides the generated IDs for individual parts.
valuestring[] | undefined—Selected values when controlled. Supports Angular two-way binding.
defaultValuestring[] | undefined[]Initial selected values when uncontrolled.
disabledbooleanfalseDisables every item in the group.
loopFocusbooleantrueWraps keyboard focus from the last item to the first.
rovingFocusbooleantrueManages a single tab stop across enabled items.
multiplebooleanfalseAllows more than one item to be selected.
deselectablebooleantrueAllows a selected item to be toggled off.
orientationToggleGroupOrientation | 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.
spacingnumber2Sets the gap CSS variable and spacing data attribute.

Use [(value)]="value" for two-way binding, or combine [value] with (valueChange) when using signals.

Outputs

OutputTypeDescription
valueChangestring[] | undefinedEmits the current selected values.
valueDetailsChangeToggleGroupValueChangeDetailsEmits details whenever selected values change.

<button appToggleGroupItem>

Inputs

InputTypeDefaultDescription
valuestringrequiredValue represented by this toggle item.
disabledbooleanfalseDisables 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

ExportAngular API
ToggleGroupRootProviderDirective that provides an externally created group API through value.
ToggleGroupContextStructural 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.
ToggleGroupImportsReadonly collection containing the toggle-group UI and context helpers.

Types

ExportDescription
ToggleGroupApiConnected toggle-group state and actions.
ToggleGroupElementIdsOverrides for generated toggle-group part IDs.
ToggleGroupItemPropsProps used to derive the state of a toggle-group item.
ToggleGroupItemStateDerived state for a toggle-group item.
ToggleGroupOrientationSupported layout and keyboard navigation orientations.
ToggleGroupValueChangeDetailsDetails emitted by valueDetailsChange.
UseToggleGroupOptionsOptions accepted by useToggleGroup.
UseToggleGroupPropsRoot props accepted by the toggle-group machine.
UseToggleGroupReturnSignal-backed toggle-group machine returned by useToggleGroup.