Checkbox Control
The checkbox control is a simple on/off switch. If enabled it outputs a boolean value of true. Disabled it returns false. You can use it to conditionally show/hide other content settings as we illustrate in the following code example:
class Prefix_Element_Checkbox extends \Bricks\Element { // Set builder controls public function set_controls() { $this->controls['exampleCheckbox'] = [ 'tab' => 'content', 'label' => esc_html__( 'Show site title', 'bricks' ), 'type' => 'checkbox', 'inline' => true, 'small' => true, 'default' => true, // Default: false ]; }
// Render element HTML public function render() { // Show site title if setting checkbox 'exampleCheckbox' is checked if ( isset( $this->settings['exampleCheckbox'] ) ) { echo get_bloginfo( 'name' ); } }}Was this helpful?
A quick vote and short notes help us improve these docs faster.
Leave a note for us
Please do not include passwords, license keys, or personal data. We store submitted notes to improve the docs.
Thanks for sharing feedback. We're using it to improve these docs.