Dark Mode

Toggle between light and dark themes with a single class.

spartan/ui supports dark mode out of the box. Add the dark class to your <html> element, and all CSS variables automatically switch to their dark mode values.

No component changes required. All spartan primitives adapt automatically.

Implementation

For a complete implementation including:

  • Persisting user preference with localStorage
  • Respecting system color scheme
  • Preventing theme flash on SSR
  • Angular service with signals

See this comprehensive guide: Dark mode with Angular & Tailwind

CLI Styles