Toggle
A two-state button that can be either on or off.
Installation
pnpm add @heyramzi/ui bits-uiUsage
import { Toggle } from "@heyramzi/ui/shadcn/toggle";Keyboard and accessibility
| Key | Does |
|---|---|
| Space Enter | Turns the toggle on or off. |
- It's a button that reports pressed or not pressed.
- An icon-only toggle needs an aria-label that names the thing it turns on, like "Bold".
API reference
variant"default" | "outline"- Default
"default" size"default" | "sm" | "lg"- Default
"default" refbindableHTMLElement | null- Default
null pressedbindableboolean- Default
false classstring...rest- Every prop of
Toggle.Rootfrombits-ui
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "default" |
size | "default" | "sm" | "lg" | "default" |
ref bindable | HTMLElement | null | null |
pressed bindable | boolean | false |
class | string | |
...rest | Every prop of Toggle.Root from bits-ui | |