Variants
Default is a whisper of pencil that becomes a highlighted, boxed button when it is on. Outline keeps its ink box the whole time. Icon-only toggles need an aria-label.
A two-state button that stays down: a whisper of pencil box at rest, and a highlighter body that snaps into register when it is on. Same Radix behavior and variants as shadcn.
npx shadcn@latest add @wobko/toggleFirst time here? Add the registry to components.json first. How to install
Default is a whisper of pencil that becomes a highlighted, boxed button when it is on. Outline keeps its ink box the whole time. Icon-only toggles need an aria-label.
Three heights, the terracotta marker for a louder switch, and disabled toggles: a dashed pencil box, and a pale wash if it is on.
A controlled toggle: the state lives in your component, the label says what pressing does, and a status line says what happened, so nothing depends on the highlighter.
Official `toggle-demo`: a small outline toggle with a bookmark and a word. shadcn fills the bookmark blue when it is on; this one keeps its highlighter body and writes the bookmark in blue felt tip, because a drawn line has no fill to change. Space or Enter toggles it.
Official `toggle-disabled`: an icon-only toggle with `disabled`. It is drawn as a dashed pencil-gray box and takes no pointer or keyboard. (The original's label says "italic" on an underline; this one says what it shows.)
Official `toggle-lg`: `size="lg"`, 40 px tall (36 in compact density, 32 in calm), for touch-first toolbars.
Official `toggle-outline`: `variant="outline"` keeps a felt-tip box around the toggle whether it is on or off; the default variant is only a whisper of pencil until it is pressed.
Official `toggle-sm`: `size="sm"`, 32 px tall, for dense toolbars.
Official `toggle-with-text`: an icon and a word. With a visible word the toggle needs no `aria-label`, and the highlighter body stretches to fit both.
A Radix Toggle (a real <button aria-pressed>) with a hand-drawn layer behind its content. Pressed state is data-state=on in CSS, so pressing never redraws anything: the highlighter body fades in, settles from a slight turn and snaps into register while the pointer is down.
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "outline" | "default" | default = a whisper of pencil box that turns into a fine-liner box with a highlighter body when on; outline = an inked box at rest that gets the body inside it. |
| size | "default" | "sm" | "lg" | "default" | 36, 32 and 40 px high, with the same minimum widths (icon squares). Compact density is one step tighter, calm two. |
| tone | "hi" | "marker" | "hi" | The color of the body when on: yellow highlighter, or terracotta marker for a louder switch. |
| pressed / defaultPressed / onPressedChange | Radix | - | Controlled and uncontrolled state, exactly as Radix Toggle. |
| asChild | boolean | false | Render your own element with the toggle's classes, state attributes and drawing inside it (Radix Slot). |
| seed | string | number | - | Pins the hand: the same seed always draws the same toggle, also across remounts. Default: derived from useId(). |
The cva function behind Toggle (also used by ToggleGroupItem). Layout and typography classes only: the drawing comes from the component.
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "outline" | "default" | Same values as Toggle. |
| size | "default" | "sm" | "lg" | "default" | Same values as Toggle. |
| className | string | - | Merged last. |
The files the CLI copies into your project.
Loading the source