SutraUI.Checkbox (Sutra UI v0.2.0)
View SourceA control that allows the user to toggle between checked and not checked.
Examples
<.checkbox name="terms" value="accepted" />
<.checkbox name="terms" value="accepted" checked />
<.checkbox name="newsletter" value="subscribed" disabled />
<.checkbox name="agree" id="agree-checkbox" required aria-describedby="agree-help" />Accessibility
- Uses semantic
<input type="checkbox">element - Supports
aria-invalidfor error states - Supports
aria-describedbyfor helper text and errors - Properly associates with labels via
idandforattributes - Respects
disabledandrequiredstates - Keyboard accessible (Space to toggle)
Summary
Functions
Renders a checkbox input element.
Functions
Renders a checkbox input element.
Examples
<.checkbox name="terms" value="accepted" />
<.checkbox name="terms" value="accepted" checked />
<.checkbox name="terms" value="accepted" disabled />Attributes
name(:string) (required) - The name attribute for the checkbox input.value(:string) - The value attribute for the checkbox input. Defaults to"true".checked(:boolean) - Whether the checkbox is checked. Defaults tofalse.disabled(:boolean) - Whether the checkbox is disabled. Defaults tofalse.class(:string) - Additional CSS classes. Defaults tonil.- Global attributes are accepted. Additional HTML attributes including ARIA. Supports all globals plus:
["id", "form", "required", "aria-invalid", "aria-describedby", "aria-required"].