Toggle Examples
7 toggle buttons that stay pressed: bold, italic and underline, a labeled toggle, the outline variant, a disabled toggle and three sizes. Each on React, Vue, Svelte and Solid, with Base UI, React Aria, Ark UI or Radix UI on React.
Every toggle example
7 examples.
- Default Size ToggleSizesOne icon button for italic at the default size, with no visible word beside the icon. It is not pressed.

- Default ToggleStandardOne icon button for bold, with no visible word. It is not pressed, and pressing it turns that state on and off.

- Disabled ToggleStandardAn underline icon button that is disabled. It stays faded on the page, and it cannot be pressed.

- Large ToggleSizesA large icon button for underline, taller than the default, with more padding around the icon.

- Outline ToggleStandardAn italic icon button with an outline border. The border is visible while the button is not pressed.

- Small ToggleSizesA small icon button for bold, shorter than the default, with tighter padding around the icon.

- Toggle with TextStandardA toggle with a bold icon and the visible word Bold beside it. The word names the button, and it is not pressed.

Or describe it. With Pro, your AI agent installs the toggle example you describe, on your framework and UI library.
Get ProGalleries
More component examples
8 related galleries, free: open one for its live examples and their code.
Pricing
Toggle examples MCP, with Pro
Your AI agent installs any of the 1364 examples, and every component, block and icon, with every Pro plan.
4.9/5 out of 5 · 150+ reviewsfrom 150+ founders and developers.
- Secure checkout via Stripe
- Code lives in your repo
- Keep what you've shipped if you cancel
- License terms
FAQ
Frequently asked questions
A button that stays pressed until you press it again: bold, italic and underline in a text editor, mute, a view option, a filter. Each example here is shadcn.io's Toggle, a real button that tells screen readers whether it's pressed, styled with Tailwind CSS. It comes for React on Base UI, React Aria, Ark UI and Radix UI, and for Vue, Svelte and Solid on Ark UI.
Yes. Every example is free to use in personal and commercial projects, with no attribution. Seeing the code and installing it takes a free shadcn.io account.
A Toggle is a button that switches an action or a formatting on and off, like bold in a toolbar. A Switch is a setting that is on or off, like dark mode. A Checkbox picks items or accepts terms, usually in a form. If it sits in a toolbar, it's a Toggle.
Use a single Toggle for an action that stands alone, like mute. When two or more toggles sit side by side, use a Toggle Group: it tracks which items are pressed, lets one or several be pressed at a time, and moves between them with the arrow keys.
Toggle has a `size` prop: `sm`, `md` (the default) and `lg`. Use `sm` in dense toolbars, `md` next to default-size buttons and inputs, and `lg` for touch screens or a few prominent controls. Keep one size per toolbar.
Put the Lucide icon alone inside the Toggle and give the Toggle an `aria-label`, such as Toggle bold, so screen readers know what it does. Hide the icon itself with `aria-hidden`.
The default variant has no border until it's pressed. `variant="outline"` adds a border, which helps on busy surfaces or next to outline buttons. The pressed state fills the background in both.
Sign in with a free account, open the example and run the install command it shows. It adds the example and the Toggle component it uses to your project, for your framework and UI library.
The Toggle keeps its own pressed state by default. To control it, pass the pressed value and listen to its change: `pressed` and `onPressedChange` on Base UI, Ark UI and Radix UI, `isSelected` and `onChange` on React Aria, `v-model:pressed` in Vue.
Disable it: `disabled` on most targets, `isDisabled` on React Aria. It stays in place, faded, and ignores clicks and the keyboard, so the toolbar doesn't shift when it comes back.
shadcn.io's Toggle (built on Base UI, React Aria, Ark UI or Radix UI in React, and on Ark UI in Vue, Svelte and Solid), Tailwind CSS and Lucide icons.
Yes. The Toggle renders a real button: Tab focuses it, Space and Enter press it, and screen readers announce whether it's pressed. An icon-only toggle needs an `aria-label`, as every icon-only example here has.
Yes, and the toggles look the same on every target: the same sizes, variants and pressed style. Only the prop names differ where the libraries differ, such as `isDisabled` on React Aria.
4.9 out of 5 from 150+ developers
Every toggle example. One prompt away.
Every toggle example is free with an account. With Pro, your AI agent installs them from a prompt.
Get Pro

















