Themes
dr-ui includes midnight (dark) and alpine (light) themes.
npx shadcn@latest add @dr-ui/themeSetup
Wrap your application with the ThemeProvider component to enable theme switching:
import { ThemeProvider } from '@/theme/theme-provider';
export default function App() {
return (
<ThemeProvider>
<YourApp />
</ThemeProvider>
);
}Using the Theme Toggle Component
The easiest way to add theme switching to your app is to use the ThemeToggle component:
npx shadcn@latest add @dr-ui/theme-toggleThen import and use it in your application:
import { ThemeToggle } from '@/components/block/theme-toggle';
function Header() {
return (
<header>
<ThemeToggle />
</header>
);
}The ThemeToggle component displays a sun icon in light mode and a moon icon in dark mode, with smooth transitions between states.
Using the Theme Hook
You can also use the useTheme hook to get the current theme and change it programmatically:
import { useTheme } from '@/theme/theme-provider';
import { Button } from '@/components/ui/button';
function CustomThemeToggle() {
const { theme, setTheme } = useTheme();
const toggleTheme = () => {
setTheme(theme === 'light' ? 'dark' : 'light');
};
return (
<Button onClick={toggleTheme}>
Current theme: {theme}
</Button>
);
}The useTheme hook returns:
theme:'light' | 'dark'- The current themesetTheme:(theme: 'light' | 'dark') => void- Function to change the theme
Color Palettes
midnight-gray
oklch(0.1933 0.0102 248.36)
oklch(0.2274 0.0108 242.21)
oklch(0.2486 0.0106 242.14)
oklch(0.2694 0.0104 242.08)
oklch(0.3058 0.0137 248.27)
oklch(0.3326 0.0143 244.06)
oklch(0.3871 0.0165 251.76)
oklch(0.5784 0.0175 248.13)
oklch(0.6731 0.0174 253.95)
oklch(0.8008 0.0144 248.01)
oklch(0.9383 0.0042 236.5)
oklch(1 0 0)
alpine-light
oklch(1 0 0)
oklch(0.9817 0.0057 264.53)
oklch(0.9634 0.0115 264.51)
oklch(0.9409 0.0126 255.51)
oklch(0.9149 0.0146 264.49)
oklch(0.8828 0.0187 258.36)
oklch(0.8486 0.0248 259.82)
oklch(0.6535 0.0284 259.04)
oklch(0.5533 0.0224 260.15)
oklch(0.4117 0.0128 261.75)
oklch(0.2352 0.0059 271.16)
oklch(0.2289 0.0074 248.15)
accent
oklch(0.9793 0.0083 271.33)
oklch(0.9592 0.019253 273.2377)
oklch(0.7766 0.1018 278.18)
oklch(0.7179 0.1312 277.26)
oklch(0.6226 0.1981 281.26)
oklch(0.5376 0.2623 279.31)
semantic
oklch(0.7752 0.1158 20.04)
oklch(0.6952 0.1538 21.86)
oklch(0.5585 0.1652 24.19)
oklch(0.4697 0.1402 24.29)
oklch(0.808 0.1696 152.96)
oklch(0.7242 0.1737 153.06)
oklch(0.5553 0.1431 152.95)
oklch(0.4643 0.1116 156.33)
oklch(0.9632 0.1493 108.9)
oklch(0.8659 0.1555 103.53)
oklch(0.5533 0.1149 79.08)
oklch(0.48 0.101 75.51)
data-viz
oklch(0.7024 0.1524 240.74)
oklch(0.4667 0.1532 256.44)
oklch(0.7828 0.1141 61.47)
oklch(0.6702 0.1689 52.07)
oklch(0.7497 0.0895 200.95)
oklch(0.6077 0.1036 204.08)
oklch(0.7578 0.1486 334.69)
oklch(0.6329 0.2142 336.99)
oklch(0.7498 0.1166 263.28)
oklch(0.6104 0.1897 262.22)
Usage
CSS variables
cssVariablesPlugin creates CSS variable for each color:
color: var(--alpine-light-40);Utility classes
Background utility available for every color:
I have turquoise bg applied
<div className='bg-turquoise-40' />