Documentation

Component: Dark / Light Theme Automatic and manual theme switching system

This module enables a dark / light theme system for your project. It supports automatic theme detection based on system preferences, time-based switching, and manual user control with persistent settings saved in localStorage.

What the theme module does

When the attribute data-anim-darklite is added to the page, the module enables automatic theme switching logic.

  • Applies light or dark theme automatically
  • Detects system theme via prefers-color-scheme
  • Allows manual switching via buttons
  • Saves user preference in localStorage
  • Supports automatic time-based theme switching
Files location
HTML / SCSS / JS files live in src/components/ui/darklite/

Enable the theme system

Add the required attribute data-anim-darklite to the page wrapper.

Enable theme module
<body data-anim-darklite>
...
</body>

Manual theme control

You can add buttons to toggle or reset the theme manually.

Theme buttons
<button data-anim-darklite-set>
Toggle theme
</button>

<button data-anim-darklite-reset>
Reset theme
</button>

Time based theme

You can enable automatic dark theme during specific hours using the attribute data-anim-darklite-time.

Time based theme
<body data-anim-darklite data-anim-darklite-time="18,5">
Example
In this example, dark mode will activate from 18:00 until 05:00.

HTML theme states

The module automatically adds theme attributes to the <html> element.

  • data-anim-darklite-light
  • data-anim-darklite-dark

Theme priority order

The module determines the active theme using the following priority:

  1. Saved user preference
  2. Time based theme
  3. System theme (prefers-color-scheme)

Download

Download Animmaster Vite Template and start building projects with a ready-to-use UI system and build pipeline.