Kodza

Theme Toggle

A button that switches the page between light and dark, sun to moon. It starts from the system, keeps the visitor's choice, and swaps images that have a night version.

Navigation No dependencies theme toggledark modelight modedark mode toggletheme switcherprefers-color-schemedata-themelocalStoragesun moon icondark logo Added Nov 2026
/anim/theme-toggle/ GitHub Fullscreen

With your AI

Just ask.

Say it to your AI. It gets the exact code below, not its best guess, and knows where it goes.

Add the Kodza Theme Toggle to my page.

Not plugged in yet?
claude mcp add -t http kodza https://kodza.dev/api/mcp
Also in Codex, Cursor and VS Code.
kodza-theme-toggle.html
<button class="kodza-theme-toggle" type="button" aria-pressed="false" aria-label="Dark mode" data-kodza-theme-toggle>
  <svg class="kodza-theme-toggle__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
    <g class="kodza-theme-toggle__rays">
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
    </g>
    <circle class="kodza-theme-toggle__disc" cx="12" cy="12" r="4"/>
  </svg>
</button>

<button class="kodza-theme-toggle kodza-theme-toggle--label" type="button" aria-pressed="false" aria-label="Dark mode" data-kodza-theme-toggle>
  <svg class="kodza-theme-toggle__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
    <g class="kodza-theme-toggle__rays">
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
      <path class="kodza-theme-toggle__ray" d="M-12 0H12"/>
    </g>
    <circle class="kodza-theme-toggle__disc" cx="12" cy="12" r="4"/>
  </svg>
  <span class="kodza-theme-toggle__words" aria-hidden="true">
    <span class="kodza-theme-toggle__word">Light</span>
    <span class="kodza-theme-toggle__word">Dark</span>
  </span>
</button>

Checked

Checked before you paste.

Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.

What ranLast run
Accessibilityaxe-core 4.10.2: the WCAG 2.1 A and AA rules, plus best practices. 0 issues
KeyboardThe Tab key gets there, and the focus ring shows when it does. Passed
Reduced motionTurn on reduced motion and what moved just appears. Nothing loops. Passed
Light and darkThe same checks on both themes, contrast included. Passed
WordPressPasted into Twenty Twenty-Five, Twenty Twenty-One, Astra, Blocksy, GeneratePress, Hello Elementor, Kadence and OceanWP. Nothing to flag. 8 / 8 themes
Robots checked this. A human with VoiceOver hasn't yet.
KeyboardPress them in the preview
On the button
  • Switches the page between light and darkEnter/Space

More like this

More in Navigation