A button that stays pressed: Bold, Pin, Mute.
$ pnpm dlx shadcn@latest add https://dashral.com/r/toggle.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/toggle.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
components.json
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/toggleUsage
example.tsx
import { Pin } from "lucide-react"
import { Toggle } from "@/components/dashral/toggle"
<Toggle aria-label="Pin" pressed={pinned} onPressedChange={setPinned}>
<Pin />
</Toggle>Examples
API reference
Toggle
Also takes every prop of Radix Toggle(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
pressed / defaultPressed / onPressedChange | booleanControlled or initial state. | — |
variant | "ghost" | "outline"Quiet until it's on, or a border all the time. | "ghost" |
size | "sm" | "default" | "lg"32, 36 or 40px tall. | "default" |
color | "primary" | "neutral" | "none"The tint when it's on: a soft primary, neutral grey for a busy toolbar, or none when what's inside shows it (a reaction's filled icon). | "primary" |
className | stringExtra classes, merged with cn() so yours win. | — |
Keyboard
| Keys | Action |
|---|---|
| EnterorSpace | Turn it on or off |
Accessibility
- A button with aria-pressed. An icon alone needs an aria-label.