Skip to main content

Checkbox

Generates a checkbox input field. There are various different options available to control the position of the checkbox and labels.

Basic usage

{{
form.checkbox({
'label': 'My label',
'id': 'checkbox-1',
'name': 'checkbox-1'
})
}}

Helper options

You can configure this helper using the common helper options, the following options are specific to this helper.

OptionTypeDescription
input_placementstringleft (default) / right position of the input vs. the label value

Disabled checkboxes

Add the 'disabled': true option to disable the field on load. See the disabling elements guide for more information about how to disable elements via javascript. Provide help text or information within the UI where possible to explain why elements are disabled.

{{
form.checkbox({
'label': 'My label',
'id': 'checkbox-2',
'name': 'checkbox-2',
'disabled': true
})
}}

Inline checkboxes

The form.checkbox_inline() helper creates a <label> element with the checkbox placed inside, this allows the checkbox to be positioned either before or after the label value through the input_placement option.

{{
form.checkbox_inline({
'label': 'Standard left aligned',
'id': 'checkbox-3',
'name': 'checkbox-3'
})
}}
{{
form.checkbox_inline({
'label': 'Right aligned',
'id': 'checkbox-4',
'name': 'checkbox-4',
'input_placement': 'right'
})
}}

Indented checkboxes

Using form.checkbox_inline will cause the checkbox input to not follow the normal flow of a regular Pulsar form. If you want to maintain form alignment, use the .form__group--indent class to restore the position.

{{
form.checkbox_inline({
'label': 'Standard inline position',
'id': 'checkbox-5',
'name': 'checkbox-5'
})
}}
{{
form.checkbox_inline({
'label': 'Indented position',
'class': 'form__group--indent',
'id': 'checkbox-6',
'name': 'checkbox-6'
})
}}