Checkbox
<esp-checkbox>
A checkbox control for toggling boolean values. Uses Tabler SVG icons for checked, unchecked, and indeterminate states. Works standalone or inside an esp-checkbox-group for multi-select.
Slots
<esp-checkbox> has a slot:
Default
The label text for the checkbox.
Attributes
<esp-checkbox> has the following attributes:
checked
checked has a default value of false.
Whether the checkbox is in the checked state.
value
value has a default value of "".
The value associated with this checkbox. Used by esp-checkbox-group to track which checkboxes are selected.
name
name has a default value of "".
The name used when the checkbox participates in a <form>.
required
required has a default value of false.
When true, the checkbox must be checked before the form can be submitted.
required-message
required-message has a default value of "".
A custom message to display when the checkbox is required but
not checked. Defaults to "Please check this box to continue."
when not set.
disabled
disabled has a default value of false.
Controls whether the checkbox is disabled.
indeterminate
indeterminate has a default value of false.
Displays the checkbox in an indeterminate (partial) state. Clicking the checkbox clears the indeterminate state.
Methods
<esp-checkbox> has the following methods:
focus
Focus the checkbox control.
validate
Re-run constraint validation and dispatch validity-changed.
checkValidity
Check whether the current state is valid (delegates to ElementInternals).
traverseToClosest
Traverse up the DOM tree to find the closest element that matches the selector. This method is aware of shadow DOM boundaries and will traverse through them to find the element.
Events
<esp-checkbox> emits the following events:
value-changed
value-changed is of type CustomEvent<{ checked: boolean; value: string }>.
Fired when the checkbox is toggled. The detail contains the new checked state and the checkbox value.
CSS Properties
<esp-checkbox> has the following CSS properties:
--esp-checkbox-size
The width and height of the checkbox icon. Defaults to var(--esp-size-normal-to-medium).
--esp-checkbox-icon-color
The stroke color of the checkbox icon. Defaults to var(--esp-color-text).
--esp-checkbox-focus-shadow
The color of the focus ring shadow. Defaults to var(--esp-color-shadow).
--esp-field-background
Background color of the shared field shell. Defaults to var(--esp-color-layer-2).
--esp-field-border-color
Border color of the shared field shell. Defaults to var(--esp-color-border).
--esp-field-border-width
Border width of the shared field shell. Defaults to 1px.
--esp-field-text-color
Text color used inside the shared field shell. Defaults to var(--esp-color-text).
--esp-field-hover-bg
Hover background color of the shared field shell. Derived from --esp-field-background.
--esp-field-focus-bg
Focus background color of the shared field shell. Derived from --esp-field-background.
--esp-field-focus-shadow
Shadow color used for shared field focus treatment. Defaults to var(--esp-color-shadow).