--- layout : 'default' css : 'checkbox' title : 'Checkbox' description : "A checkbox visually indicates the status of a user's selection" type : 'UI Module' --- <%- @partial('header') %>

Usage

Check Box

A standard checkbox

Javascript
$('.ui.checkbox') .checkbox() ;
HTML

Static Check Box

A checkbox can also be used without using javascript by creating the check box as a label with a for tag matching the id attribute of the input field.

HTML Only

Types

Slider

A checkbox can be formatted to show user selection as a slider

Toggle

A checkbox can be formatted to show user selection as a toggle

Radio Box

A checkbox can be formatted as a radio element. This means it is an exclusive option.

Variations

Size

A checkbox can be a different size.

Behavior

A checkbox can change to show a user has selected it

$('.ui.checkbox') .checkbox('enable') ;

A checkbox can change to show a user has not selected it

$('.ui.checkbox') .checkbox('disable') ;

A checkbox can toggle between states

$('.ui.checkbox') .checkbox('toggle') ;

Examples

Example of using checkbox states to alter multiple checkboxes

$('.enable.button') .on('click', function() { $(this) .parent() .nextAll('.checkbox') .checkbox('enable') ; }) ; $('.disable.button') .on('click', function() { $(this) .parent() .nextAll('.checkbox') .checkbox('disable') ; }) ; $('.toggle.button') .on('click', function() { $(this) .parent() .nextAll('.checkbox') .checkbox('toggle') ; }) ;
Enable
Disable
Toggle


Settings

Checkbox Settings
required auto Setting to true/false will determine whether an input will allow no selection. Auto will set disallow this behavior only for radio boxes
context false A selector or jQuery object to use as a delegated event context
Callbacks
onChange None Callback after a checkbox is either disabled or enabled.
onEnable None Callback after a checkbox is enabled.
onDisable None Callback after a checkbox is disabled.

DOM Settings

DOM settings specify how this module should interface with the DOM

Setting Default Description
namespace checkbox Event namespace. Makes sure module teardown does not effect other events attached to an element.
selector
selector : { input : 'input', label : 'label' }
className
className : { radio : 'radio' }