Measured entry

shadcn-switch

switchunclassified

A client-side React switch that wraps the Radix Switch primitive and ships as source code for your app. Its styling is expressed through Tailwind utility classes and theme tokens, while class merging comes from the local cn helper backed by clsx and tailwind-merge.

Specimen
Harness screenshot of shadcn-switch at 375 pixels wide
Harness screenshot at 375 pixels wide. No horizontal overflow recorded.
Harness screenshot of shadcn-switch at 768 pixels wide
Harness screenshot at 768 pixels wide. No horizontal overflow recorded.
Harness screenshot of shadcn-switch 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-switch
BuildOK
MountOK
Console errors0
Uncaught page errors0
Horizontal overflowclean at 375, 768, 1440
Axe critical0
Axe serious0
Axe moderate0
Axe minor0
Gzip marginal34.4 KB (99.9 KB build, 65.5 KB baseline)
Bare modeOK
Provider requiredNO
Demo usedwritten from the component source API

Verdict

A dependable, narrowly scoped switch for React teams already aligned with Radix and Tailwind. It built and mounted cleanly in both configured and bare checks, so the main tradeoff is adopting its styling conventions and runtime primitive for a very small control.

Use it if

  • You need an accessible on-or-off control that fits an existing shadcn and Tailwind design system.
  • You want a controlled or uncontrolled React switch whose source can be adjusted locally.
  • You already use Radix primitives and want consistent focus, disabled, size, and dark-theme states.

Skip it if

  • Your product needs a checkbox rather than a switch because the choice is submitted with a form instead of taking effect immediately.
  • Your app does not use Tailwind or shadcn theme tokens and you do not want to translate its utility classes.
  • You want a dependency-free native control and do not need Radix state handling.

Install

Installation record for shadcn-switch
Declared dependenciesradix-ui, clsx, tailwind-merge
Missing on installnone
Bare installbuilds and mounts without the shadcn-style helpers
Providerno provider required in the harness

In a non-shadcn project, add radix-ui, Tailwind CSS, and a cn helper backed by clsx and tailwind-merge. Define the referenced color, border, focus-ring, shadow, and dark-theme tokens, and replace the @ alias import if your build does not resolve it.

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.