# 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::addField( 'OPT_NAME', 'SECTION_ID', array(
    'id'       => 'opt-switch',
    'type'     => 'switch', 
    'title'    => __('Switch On', 'redux-framework-demo'),
    'subtitle' => __('Look, it\'s on!', 'redux-framework-demo'),
    'default'  => true,
) );

# Example Usage

This example in 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'];