Search documentation

Search the documentation and open a page.

A two-state button that can be either on or off.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/toggle

Composition

<button appToggle> └── <app-toggle-indicator> (optional)

Examples

Default

Loading...

Disabled

Loading...

Sizes

Loading...

Variants

Loading...

With Icon

Loading...

With Tooltip

Loading...

API Reference

<button appToggle>

Inputs

InputTypeDefaultDescription
disabledbooleanfalseDisables interaction with the toggle.
pressedboolean | undefined—Pressed state when controlled. Supports Angular two-way binding.
defaultPressedbooleanfalseInitial pressed state when uncontrolled.
size"default" | "sm" | "lg""default"Sets the toggle's visual size.
variant"default" | "outline""default"Sets the toggle's visual treatment.

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

Outputs

OutputTypeDescription
pressedChangeboolean | undefinedEmits the current pressed state.

Context, Providers, and Utilities

ExportAngular API
ToggleRootProviderDirective that provides an externally created toggle API through value.
ToggleContextStructural directive [toggle-context] exposing the root API to a template.
useToggle(options?)Creates the signal-backed toggle machine inside an injection context.
injectToggleContext()Injects the nearest toggle root context.
toggleVariantsStyle recipe used to reuse the toggle size and variant classes.
ToggleImportsReadonly collection containing the toggle UI and context helpers.

Types

ExportDescription
ToggleApiConnected toggle state and actions.
UseToggleOptionsOptions accepted by useToggle.
UseTogglePropsRoot props accepted by the toggle machine.
UseToggleReturnSignal-backed toggle machine returned by useToggle.