Options

NameAttributeTypeDescriptionValuesDefault
statecheckedBooleanThe checkbox statetrue, falsetrue
sizedata-sizeStringThe checkbox sizenull, 'mini', 'small', 'normal', 'large'null
animatedata-animateBooleanAnimate the switchtrue, falsetrue
disableddisabledBooleanDisable statetrue, falsefalse
readonlyreadonlyBooleanReadonly statetrue, falsefalse
indeterminatedata-indeterminateBooleanIndeterminate statetrue, falsefalse
inversedata-inverseBooleanInverse switch directiontrue, falsefalse
radioAllOffdata-radio-all-offBooleanAllow this radio button to be unchecked by the usertrue, falsefalse
onColordata-on-colorStringColor of the left side of the switch'primary', 'info', 'success', 'warning', 'danger', 'default''primary'
offColordata-off-colorStringColor of the right side of the switch'primary', 'info', 'success', 'warning', 'danger', 'default''default'
onTextdata-on-textStringText of the left side of the switchString'ON'
offTextdata-off-textStringText of the right side of the switchString'OFF'
labelTextdata-label-textStringText of the center handle of the switchString' '
handleWidthdata-handle-widthString | NumberWidth of the left and right sides in pixels'auto' or Number'auto'
labelWidthdata-label-widthString | NumberWidth of the center handle in pixels'auto' or Number'auto'
baseClassdata-base-classStringGlobal class prefixString'bootstrap-switch'
wrapperClassdata-wrapper-classString | ArrayContainer element class(es)String | Array'wrapper'
onInitFunctionCallback function to execute on initializationFunction
function(event, state) {}
onSwitchChangeFunctionCallback function to execute on switch state change. If false is returned, the status will be reverted, otherwise nothing changesFunction
function(event, state) {}

Global Defaults Overriding

Follow the jQuery convention to override the default options of the library. For instance:

$.fn.bootstrapSwitch.defaults.size = 'large';
$.fn.bootstrapSwitch.defaults.onColor = 'success';