
BrowserUX Theme Switcher
A modern solution to offer a light/dark theme selector and enhance the user experience across all your web interfaces.
BrowserUX Theme Switcher is a lightweight, accessible, and customizable Web Component designed to easily add a theme switcher button to any website or application. It automatically detects the system theme, remembers the user's preference, and applies the correct theme.
Download v1.0.0
pure HTML, React, Vue or Angular
See the CHANGELOG
npm install browserux-theme-switcher
Features
-
🎛 Smart Behavior
-
Theme Switching
Toggles betweendata-theme="light"
and"dark"
on a target element (default ishtml
) -
Automatic Persistence
Stores the user's preference inlocalStorage
and restores it on each visit -
System Detection
Automatically enables the theme based onprefers-color-scheme
if no preference is set -
theme-change
Event
Fires a custom event on every theme change (e.detail.theme = "light" | "dark"
)
-
Theme Switching
-
🎨 Visual Customization
-
CSS Targeting (
target
)
Allows applying the theme to a specific element (e.g.,main
,#app
, etc.) -
Customizable CSS Variables
Extensive appearance customization via CSS properties (--bux-switch-*
) -
Custom Slots for Icons
Customize icons using SVG tags, emojis, or images (light-icon
,dark-icon
) -
Adaptive Images (
.has-dark
)
Automatically switch images based on the theme (e.g.,logo.png
→logo-dark.png
)
-
CSS Targeting (
-
♿ Accessibility & Internationalization
-
Dynamic ARIA Labels
Multilingual accessible texts automatically generated or customizable viadata-label-*
-
Internationalization (
lang
)
Support for multiple languages (auto-detection or forced via thelang
attribute)
-
Dynamic ARIA Labels
-
🔧 Flexible Integration
-
Optional Shadow DOM (
no-shadow
)
Shadow DOM encapsulation can be disabled to allow more flexible global styling
-
Optional Shadow DOM (