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
<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
| Input | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disables interaction with the toggle. |
pressed | boolean | undefined | — | Pressed state when controlled. Supports Angular two-way binding. |
defaultPressed | boolean | false | Initial 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
| Output | Type | Description |
|---|---|---|
pressedChange | boolean | undefined | Emits the current pressed state. |
Context, Providers, and Utilities
| Export | Angular API |
|---|---|
ToggleRootProvider | Directive that provides an externally created toggle API through value. |
ToggleContext | Structural 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. |
toggleVariants | Style recipe used to reuse the toggle size and variant classes. |
ToggleImports | Readonly collection containing the toggle UI and context helpers. |
Types
| Export | Description |
|---|---|
ToggleApi | Connected toggle state and actions. |
UseToggleOptions | Options accepted by useToggle. |
UseToggleProps | Root props accepted by the toggle machine. |
UseToggleReturn | Signal-backed toggle machine returned by useToggle. |
Angular
React
Solid
Svelte
Vue