pro-ui

Theming

Dark/light/system mode and custom color tokens in @dangbt/pro-ui.

pro-ui uses CSS semantic tokens with Tailwind CSS v4. Dark mode works automatically — no configuration needed.

ThemeProvider

Wrap your app with ThemeProvider:

import { ThemeProvider } from '@dangbt/pro-ui'
 
export default function App() {
  return (
    <ThemeProvider>
      {/* your app */}
    </ThemeProvider>
  )
}

ThemeProvider defaults to system (follows OS preference). It persists the user's choice in localStorage.

useTheme hook

import { useTheme } from '@dangbt/pro-ui'
 
function ThemeToggle() {
  const { theme, setTheme } = useTheme()
 
  return (
    <button onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>
      {theme === 'dark' ? '☀️' : '🌙'}
    </button>
  )
}

useTheme return value

PropertyTypeDescription
theme'light' | 'dark' | 'system'Current theme setting
resolvedTheme'light' | 'dark'Actual applied theme (resolves system)
setTheme(theme: Theme) => voidUpdate theme

Custom primary color

Override the --primary CSS variable in your stylesheet:

/* src/index.css */
@import "tailwindcss";
@import "@dangbt/pro-ui/styles";
 
:root {
  --primary: 234 89% 74%;         /* indigo */
  --primary-foreground: 0 0% 100%;
}
 
/* Optional: different value for dark mode */
.dark {
  --primary: 234 89% 60%;
}

The color format follows HSL without hsl() — just the three values, space-separated.

Example: change to blue

:root {
  --primary: 217 91% 60%;     /* blue-500 */
  --primary-foreground: 0 0% 100%;
}

Example: change to emerald

:root {
  --primary: 160 84% 39%;     /* emerald-600 */
  --primary-foreground: 0 0% 100%;
}

Token reference

TokenLightDarkUsage
--backgroundwhitegray-950Page background
--foregroundgray-900gray-50Default text
--mutedgray-100gray-800Muted backgrounds
--muted-foregroundgray-500gray-400Secondary text
--bordergray-200gray-700Borders and dividers
--primaryindigo-500indigo-400Brand color
--primary-foregroundwhitewhiteText on primary
--destructivered-500red-400Error/danger
--successemerald-500emerald-400Success states

On this page