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.

Specimen
Motion capture of the mounted demo, recorded by the harness. No audio track.
Harness screenshot of ruixen-animated-theme-toggler at 375 pixels wide
Harness screenshot at 375 pixels wide. No horizontal overflow recorded.
Harness screenshot of ruixen-animated-theme-toggler at 768 pixels wide
Harness screenshot at 768 pixels wide. No horizontal overflow recorded.
Harness screenshot of ruixen-animated-theme-toggler 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 ruixen-animated-theme-toggler
BuildOK
MountOK
Console errors0
Uncaught page errors0
Horizontal overflowclean at 375, 768, 1440
Axe critical0
Axe serious0
Axe moderate0
Axe minor0
Gzip marginal61.8 KB (127.3 KB build, 65.5 KB baseline)
Bare modeOK
Provider requiredNO
Demo usedwritten 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

Installation record for ruixen-animated-theme-toggler
Declared dependenciesmotion
Missing on installnone
Bare installbuilds and mounts without the shadcn-style helpers
Providerno 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.

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.