Skip to content

zk-switch ​

Styled checkbox rendered as a toggle switch. Delegates to zk-checkbox with a switch field class applied automatically.

Also available as x-zk-toggle, the name that @zairakai/vue-components gives it.

Props ​

PropTypeDefaultDescription
namestring|nullnullname attribute
idstring|nullnullid — falls back to name
valuemixednullvalue attribute
checkedboolfalsePre-checked state
labelstring|nullnullLabel text
classstring|nullnullCSS class(es) on the input
fieldbooltrueWrap in field structure
fieldClassstring|nullnullAdditional field class — merged with base switch class

Examples ​

Basic toggle ​

blade
<x-zk-switch name="notifications" label="Enable notifications" />

Pre-enabled ​

blade
<x-zk-switch name="dark_mode" label="Dark mode" :checked="$user->dark_mode" />

Without field wrapper ​

blade
<x-zk-switch name="active" :field="false" :checked="true" />

Notes ​

  • Always renders with class="switch" on the field wrapper — this is the CSS hook for toggle styling.
  • Visually depends on CSS in the consuming application.

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