# Switch

The Switch field sets a true or false value based on the selection. Users may also change the labels of the switch.

# Arguments

Name Type Default Description
type string switch Value identifying the field type.
on string On Text displayed for the true value.
off string Off Text displayed for the false value.

# Build Config

Build a Custom Configuration →
Changes you make to this form will be reflected in the generated code.
Field visibility requirements.

Redux::set_field( 'OPT_NAME', 'SECTION_ID', array(
    'type' => 'switch'
) );

# Example Config

Redux::set_field( 'OPT_NAME', 'SECTION_ID', array(
    'id'       => 'opt-switch',
    'type'     => 'switch', 
    'title'    => esc_html__('Switch On', 'your-textdomain-here'),
    'subtitle' => esc_html__('Look, it\'s on!', 'your-textdomain-here'),
    'default'  => true,
) );

# Example Usage

This example is based on the example usage provided above. Be sure to change $redux_demo to the value you specified in your opt_name argument.

global $redux_demo;

echo 'Switch value: ' . $redux_demo['opt-switch'];