The "toggle" control

Learn how to create controls using Kirki

Back to Controls


The documentation site is currently being rewritten. If you can't find what you're looking for please check the github issues and ask for assistance there until the documentation rewrite is complete.

Toggles provide a simple way to turn on/off options. They return a boolean so you can easily check their value in your code and act on them (check the examples for more details).

Toggle controls are internally checkbox controls styled differently.


Kirki::add_field( 'theme_config_id', array(
	'type'        => 'toggle',
	'settings'    => 'my_setting',
	'label'       => esc_attr__( 'This is the label', 'textdomain' ),
	'section'     => 'section_id',
	'default'     => '1',
	'priority'    => 10,
) );


<?php if ( true == get_theme_mod( 'my_setting', true ) ) : ?>
	<p>Toggle is enabled</p>
<?php else : ?>
	<p>Toggle is disabled</p>
<?php endif; ?>
Edit this page