Skip to content

zk-theme-switcher ​

Buttons that choose the colour scheme and remember it.

Props ​

PropTypeDefaultDescription
modesarray['light', 'dark', 'system']The modes
labelsarray['light' => 'Light', 'dark' => 'Dark', 'system' => 'System']Text of each mode
labelstring'Theme'Accessible name of the group
storageKeystring'zk-theme'Key of the localStorage
attributestring'data-theme'Attribute set on <html>
defaultstring'system'Mode without a stored choice
classstring|nullnullCSS class(es) merged onto the root element

Undeclared attributes forward to the root element.

Needs the script theme of zk-scripts: the component asks for it by itself. It sets the attribute on <html> (system removes it) and aria-pressed on the buttons. Write your colours for html[data-theme="dark"].

Examples ​

Basic ​

blade
<x-zk-theme-switcher />

Documentation of 3.2.0 , built from c93e21f on 3.2.0 by pipeline #2919741884 on 2026-10-06.