Checkbox
Displays a form checkbox.
Requires JS
This component requires the checkbox stimulus controller.
API Reference
Checkbox
| Name | Type | Default |
|---|---|---|
name: | string | nil |
value: | string | "1" |
| Value sent to the server when the checkbox is checked. | ||
unchecked_value: | string | "0" |
Value sent to the server when the checkbox is unchecked. Only used when include_hidden is true. | ||
checked: | boolean | false |
| Initial checked state of the checkbox. When true, the checkbox will appear selected on page load. | ||
include_hidden: | boolean | true |
| Whether to include a hidden field that ensures a value is sent even when the checkbox is unchecked. | ||
attributes | keyword arguments | |
Keyboard Interactions
| Key | Description |
|---|---|
| Space | Checks/unchecks the checkbox. |
Examples
On This Page