Measured entry

shadcn-toggle

switchunclassified

A client-side React pressed-state button copied into your app as source, wrapping the Radix UI Toggle primitive. Its visual variants use class-variance-authority, Tailwind utility classes, and a local cn helper backed by clsx and tailwind-merge.

Specimen
Harness screenshot of shadcn-toggle at 375 pixels wide
Harness screenshot at 375 pixels wide. No horizontal overflow recorded.
Harness screenshot of shadcn-toggle at 768 pixels wide
Harness screenshot at 768 pixels wide. No horizontal overflow recorded.
Harness screenshot of shadcn-toggle at 1440 pixels wide
Harness screenshot at 1440 pixels wide. No horizontal overflow recorded.

Measured

Every value below was written by the harness on the run that produced the frames above. None of it is derived from the prose.

Harness measurements recorded for shadcn-toggle
BuildOK
MountOK
Console errors0
Uncaught page errors0
Horizontal overflowclean at 375, 768, 1440
Axe critical0
Axe serious0
Axe moderate0
Axe minor0
Gzip marginal32.8 KB (98.3 KB build, 65.5 KB baseline)
Bare modeFAIL
Provider requiredNO
Demo usedwritten from the component source API

What the harness recorded

BARE BUILD

✗ Build failed in 896ms
error during build:
[vite]: Rollup failed to resolve import "class-variance-authority" from "<sandbox>re-2ba5c3265590/src/cut/components/ui/toggle.tsx".

Verdict

A dependable choice for compact, independently toggled actions. It built and mounted cleanly, stayed responsive, and produced no detected accessibility violations. The main tradeoff is adopting its Tailwind token conventions and Radix dependency for a small control.

Use it if

  • You need an independently pressed toolbar action such as bold, mute, or pin.
  • Your app already uses Tailwind and shadcn-style theme tokens.
  • You want Radix-managed keyboard, focus, disabled, and controlled-state behavior while retaining local source ownership.

Skip it if

  • You need a mutually exclusive or coordinated set of controls, where Toggle Group is the better primitive.
  • You need a form setting presented as an on-off switch rather than a pressed button.
  • Your project does not use Tailwind and you do not want to translate its theme-token classes.
  • You want a dependency-free button and can implement pressed-state behavior yourself.

Install

Installation record for shadcn-toggle
Declared dependenciesradix-ui, clsx, tailwind-merge
Missing on installnone
Bare installfails once the shadcn-style helpers are removed, so it needs that setup
Providerno provider required in the harness

In a non-shadcn project, add Radix UI, class-variance-authority, clsx, and tailwind-merge; provide the cn class-merging helper; and define or replace the Tailwind theme-token utilities used for muted, accent, input, ring, and destructive states. Keep it in a client-rendered React boundary.

Source and credit

This page is a review, not a copy. The component source lives with its author and this site does not republish it. Read the license before you use anything.

Author repository

github.com/shadcn-ui/ui
License
MIT
Record published
2026-08-16

Alternatives

Other published entries for the switch pattern, ordered by what they measured: mounts first, then clean axe scans, then bare-mode passes, then the smaller bundle.