Checkbox
Checkboxes are used to let users select 1 or more options on a form.
When to use this component
Use checkboxes when you need to help users:
- select more than 1 option from a list
- toggle a single option on or off
When not to use this component
Do not use the checkboxes component if users can only choose 1 option from a selection. In this case, use a radio.
Variations
Minimal checkbox
open this example in its own window
<div class="form-check">
<input class="form-check-input" type="checkbox" value="yes" id="ds-id-0" />
<label class="form-check-label" for="ds-id-0">Lorem ipsum</label>
</div>
Options to the checkbox()
macro
{% from 'macros/component/checkbox.html' import checkbox %}
{{ checkbox({
'label': 'Lorem ipsum',
'value': 'yes'
}) }}
Required checkbox
open this example in its own window
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
value="yes"
id="ds-id-1"
required
/>
<label class="form-check-label" for="ds-id-1">Lorem ipsum</label>
</div>
Options to the checkbox()
macro
{% from 'macros/component/checkbox.html' import checkbox %}
{{ checkbox({
'label': 'Lorem ipsum',
'value': 'yes',
'required': true
}) }}
Disabled checkbox
open this example in its own window
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
value="yes"
id="ds-id-2"
disabled
/>
<label class="form-check-label" for="ds-id-2">Lorem ipsum</label>
</div>
Options to the checkbox()
macro
{% from 'macros/component/checkbox.html' import checkbox %}
{{ checkbox({
'label': 'Lorem ipsum',
'value': 'yes',
'disabled': true
}) }}