Argent

ThemeToggle

Switches between dark and light with a circular reveal. Web only.

import { ThemeToggle } from '@rajatweb/argent'

<ThemeToggle onThemeChange={track} />

Props

PropTypeDefaultWhat it does
label(next: ThemeName) => stringAccessible name for the theme a press will switch to.
onThemeChange(theme: ThemeName) => void
persistbooleantrueRemember the choice for the next visit.

Accessibility

  • Named by the theme it switches to.
  • Switches instantly for reduced motion.

Do

  • Inline `themeScript` in the head so a saved theme applies before first paint.

Don’t

  • Put two on one page.