Loading
Loading
Loading
mobile footer

Build the Interaction Layer Your Website is Missing.

Browse All EffectsBrowse All EffectsBrowse All EffectsUpgrade to ProUpgrade to ProUpgrade to Pro

80+ effects free, forever. No credit card.

© 2026 Hyperiux. All Rights Reserved.

AI Component CatalogueHey AI, Learn About Us
Platform

Vault

  • Documentation
  • Pricing
  • Blog
  • Community
  • NPM
  • MCP

Categories

  • All Effects
  • WebGL
  • Text
  • Backgrounds
  • Buttons
  • Carousels
  • Scroll
  • Components
  • Navigation
  • Cursor
  • Transitions
  • Loaders

Documents

  • Introduction
  • Installation
  • CLI
  • Dependencies
  • License

Legal

  • License Agreement
  • Terms of Service
  • Privacy Policy
  • Refund Policy
Socials
  • Twitter / X
  • LinkedIn
  • GitHub
  • Instagram
Contact Us
  • hello@hyperiux.com
New effects, in your inbox

Every new drop, plus the occasional behind-the-scenes build. No spam. Unsubscribe anytime.

Loading
Home/Theme Switch Component

Theme Switch Component

An animated theme switch with circular reveals, page-wide swipe and fade transitions, and interactive sun and moon icons for light and dark mode switching.

@base-ui/reactclass-variance-authoritygsaplucide-reactmotiontailwind-merge
DemoDemoDemo

Tune the Real Props

Overview

Theme Switch spreads the new theme from the button in a circular reveal, sweeps it across the viewport, or fades it in, so users keep their place. The sun and moon icons spin or orbit as the theme changes, and an optional tooltip labels the icon-only button.

Use it when a product offers both light and dark modes and lets users choose, such as dashboards, docs, portfolios, and developer tools. The theme itself matters more than the transition.


Theme and Interaction Customisation

Adjust the button’s background, border, and text treatment, use an outline style, and add an optional tooltip. Transitions can be a circular reveal, swipe, or fade with adjustable duration, and the icons can spin or orbit.


Example Production Use Case

A SaaS analytics dashboard can put Theme Switch in its header. Switching to dark mode reveals from the button across charts and tables while filters and the current view stay exactly as they were.

A documentation site can use the fade transition so readers switch to dark mode for long sessions without a jarring flash.

A creative portfolio can lean into the orbiting icon and swipe reveal as a signature detail that shows off two distinct visual treatments of the same work.


Best Used For

  • SaaS dashboards.
  • Developer tools and code editors.
  • Content websites, blogs, and knowledge bases.
  • Productivity applications.
  • Creative portfolios.
  • Compact application headers and toolbars.
  • Design system showcases.

Not For

Skip it if the product only has one complete theme, since a half-built dark mode feels inconsistent.

Avoid page-wide reveals where colour changes must be instant for operational or accessibility reasons.

It can’t hide incomplete theming in charts or dialogs, and products bound by an organisation-wide appearance policy may not need a user toggle.


Performance Budget

Switch themes through a shared class or token system rather than re-rendering the app, and keep transitions short. Test reveals on heavy pages and low-powered phones, prevent stacking animations on repeated clicks, and fall back to an instant switch without View Transitions or with reduced motion.


Accessibility and Mobile

Use a button with a clear accessible name, either a stable label with aria-pressed or an action label that updates, plus Enter and Space activation and visible focus. On mobile, keep it easy to tap and ensure the reveal covers the whole viewport. Both themes need good contrast, and reduced motion should disable reveals and icon rotation.


Common Mistakes

  • Revealing the theme before its styles are ready.
  • Breaking theme switching in browsers without View Transitions.
  • Starting the circular reveal from the wrong origin.
  • Letting rapid clicks leave an intermediate theme.
  • Flashing the wrong theme on initial load.
  • Styling only the page background.
  • Relying on the icon alone to explain the control.
  • Ignoring reduced-motion preferences.

Changelog

v1.0.0

Oct 23, 2026
Initial release

API Reference

PropTypeDefaultDescription
themestringspotifyColour palette. Any theme but Default also tints the sun and moon icon, except on the Default button, which is already primary.
revealAnimationstringcircleHow the new theme spreads over the old one.
durationnumber0.85How long the theme change takes, in seconds.
iconAnimationstringorbitHow the sun and moon icons swap.
showTooltipbooleantrueShows a tooltip naming the theme the button switches to.
variantstringoutlineStyle of the button: outline, ghost (no border) or filled.

Questions, Answered.

What is Theme Switch?

Theme Switch is an animated React component for switching between light and dark modes, with page-wide reveal transitions and interactive sun and moon icons.

What theme transition animations are available?

A circular reveal from the button, a page-wide swipe, and a fade.

What happens if the browser does not support View Transitions?

The theme switches immediately without the animated reveal, so functionality never depends on it.

Can the sun and moon icons animate?

Yes. Spin rotates the icons into place, while Orbit moves the sun and moon around each other.

Does Theme Switch automatically remember user preferences?

No. Persistence isn’t part of the published API, so connect it to your theme provider or storage.

Can Theme Switch be used with Next.js?

Yes. Transitions run client-side, and the app should align the initial theme with server rendering to avoid a flash.

View MoreView More

Request a Custom Animation

Need a custom effect? Tell us what to create.

Related Effects

Explore All EffectsExplore All EffectsExplore All Effects
Menubar Component
@base-ui/reactlucide-reactmotion

Menubar Component

Components

Table Component
@base-ui/reactclass-variance-authoritygsap

Table Component

Components

Command Component
@base-ui/reactclass-variance-authoritycmdk

Command Component

Components

All Effects
Featured ComponentsText AnimationsAnimated BackgroundsAnimated ButtonsCarousel EffectsScroll EffectsCreative ComponentsNavigationsCursor EffectsTransitionsLoadersWebGL & 3D Effects
Templates
IntroductionInstallationCLIDependenciesLicense
PricingBlogGithubNPMMCP Doc