Color scheme

Dark mode without the flash.

Light, dark and system modes that persist, stay in sync across tabs and apply before the first paint.

Features

What it handles for you

Correct from first paint

The inline head script applies the stored or system scheme before the stylesheet renders.

Persistent and synchronized

A visitor's choice persists across navigation and stays aligned across toggles and browser tabs.

System-aware by default

System mode follows prefers-color-scheme and reacts when the OS preference changes.

Installation

Add color schemes in two steps

1

Add the script before CSS

Put the script in <head>, before @vite, so the preference is resolved before the stylesheet can paint.

Blade layout
{{-- resources/views/components/layouts/app.blade.php --}}
<head>
    <hw:color-scheme.script />
    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
2

Render a toggle in the body

Place the toggle in a header, menu, or settings screen. Multiple toggles share the same preference automatically.

Blade layout
{{-- Anywhere inside <body> --}}
<hw:color-scheme.toggle
    aria-label="Toggle color scheme"
    tooltip="Toggle color scheme"
/>

Default setup complete

No controller registration or custom storage code is required. The default mode is system, and the toggle cycles through light dark system.

Configuration

Change only what your product needs

modes

Controls the available modes and their cycle order.

default

Sets the fallback when no valid preference is stored.

view-transition

Adds a progressive cross-fade when the scheme changes.

Choose a cycle

Use all three modes for preference-aware interfaces, or limit the cycle to a direct light/dark toggle. Changes synchronize with the toggle in the top bar.

Three-mode cycle

Light, dark, and system

Two-mode cycle

Light and dark only

The colors of each mode come from your theme tokens. Tune both in the Theme Lab.

Keep shared settings aligned

If you customize storage-key or default, pass the same values to <hw:color-scheme.script> and every <hw:color-scheme.toggle>.

See it all working together

The Task manager combines components, controllers, frames, streams and overlays in one workflow.

Open the playground