Skip to content
Flat Meet

ThemeToggle

Actions

One button that switches between dark and light on each click; dark until the person picks, whatever the device prefers. It shows where a click goes: the sun in dark mode, the moon in light mode. In the header of every workspace page. Remembered in the browser and applied before the first paint, so it never flashes.

Source

src/components/layout/ThemeToggle.tsx
View in Storybook

Usage

Switch the theme

Guidelines

  • Reuse it anywhere there is a header
  • Set the theme from code with setTheme('light' | 'dark') from @/lib/theme

Accessibility

  • Its name says the current theme and what a click does, such as "Theme: dark (switch to light)" (in Thai when the app is in Thai)
  • A tooltip names the action for people who see only the icon