Theme Switcher
Theme Switcher - Default
A theme switcher component with light and dark mode options
Loading...
Usage
The Theme Switcher component provides an elegant way to toggle between light and dark themes in your application. It uses next-themes
for theme management and supports internationalization through next-intl
.
Features
- Automatically detects and displays current theme with dynamic icon (Sun/Moon)
- Smooth transition between available themes
- RTL support for Arabic language
- Accessible dropdown menu interface
- Internationalized theme names using next-intl
- Dynamic theme list from next-themes configuration
Implementation
The component uses:
next-themes
for theme management and detectionnext-intl
for internationalization of theme names- Radix UI-based dropdown menu for theme selection
- Dynamic icon switching based on resolved theme
- RTL-aware dropdown positioning
Code Structure
Props
The ThemeSwitcher component is self-contained and uses context providers from next-themes
and next-intl
. It doesn't accept any props as it manages all state internally.
Dependencies
Prop | Type | Default |
---|---|---|
size? | "default" | "heightless" | "xs" | "sm" | "lg" | "xl" | "icon" | "smallIcon" | "default" |