toggle

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.

Example

Kirki::add_field( 'theme_config_id', [
	'type'        => 'toggle',
	'settings'    => 'toggle_setting',
	'label'       => esc_html__( 'This is the label', 'kirki' ),
	'section'     => 'section_id',
	'default'     => '1',
	'priority'    => 10,
] );

Usage

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

Last updated on: May 10th, 2020

Scroll to Top

Download

Subscribe & be the first to be informed about
new features & updates!