Measured entry
ruixen-animated-theme-toggler
switchunclassifiedmotion on file
A client-side React button that morphs an inline SVG between sun and moon states, toggles the document root's dark class, and can synthesize a click sound with the Web Audio API. It ships as a shadcn registry item but uses no shadcn primitives; its only added package dependency is Motion.



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.
| Build | OK |
|---|---|
| Mount | OK |
| Console errors | 0 |
| Uncaught page errors | 0 |
| Horizontal overflow | clean at 375, 768, 1440 |
| Axe critical | 0 |
| Axe serious | 0 |
| Axe moderate | 0 |
| Axe minor | 0 |
| Gzip marginal | 61.8 KB (127.3 KB build, 65.5 KB baseline) |
| Bare mode | OK |
| Provider required | NO |
| Demo used | written from the component source API |
Verdict
A polished morph with clean standalone mounting, but it is best as a starting point rather than a complete theme system. Use it when root-class toggling matches your architecture, then add focus styling and connect persistence if needed.
Use it if
- Your theme is controlled by a dark class on the document root.
- Motion is already in the app, or the animated icon justifies adding it.
- You want a compact icon-only control with optional interaction sound.
Skip it if
- Your theme state is owned by a provider that must handle persistence, system preference, or cross-tab updates.
- You need a visible keyboard focus treatment without modifying the component's outline styles.
- Adding Motion for a single theme icon is not worth the dependency cost.
- Your interface must avoid audio by default unless you remember to disable the sound prop.
Install
| Declared dependencies | motion |
|---|---|
| Missing on install | none |
| Bare install | builds and mounts without the shadcn-style helpers |
| Provider | no provider required in the harness |
In a non-shadcn React project, add Motion, copy the client component, and ensure your dark-theme CSS responds to the document root's dark class. Add your own persistence or provider synchronization, restore a visible focus style, and disable sound when audio is inappropriate.
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/ruixenui/ruixen.comAlternatives
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.
- neu-toggleneumorphism
- Renders
- YES
- A11y
- 0
- Gzip
- 17.8KB
- Bare
- pass
- Prov
- NO
- clay-toggleclaymorphism
- Renders
- YES
- A11y
- 0
- Gzip
- 18.2KB
- Bare
- pass
- Prov
- NO
- ruixen-scrub-datetimeunclassified
- Renders
- YES
- A11y
- 0
- Gzip
- 22.2KB
- Bare
- pass
- Prov
- NO
- shadcn-switchunclassified
- Renders
- YES
- A11y
- 0
- Gzip
- 34.4KB
- Bare
- pass
- Prov
- NO
- hextaui-switchminimal-flat
- Renders
- YES
- A11y
- 0
- Gzip
- 34.5KB
- Bare
- pass
- Prov
- NO
- hextaui-tabsminimal-flat
- Renders
- YES
- A11y
- 0
- Gzip
- 39.0KB
- Bare
- pass
- Prov
- NO