Provides standard checkboxes and toggle switches.
The q2-checkbox
supports the use of custom content that will be treated as the label of the field.
<q2-checkbox>
<div>
<strong>Content can be yielded here</strong>
</div>
<div>
Formatting is <em>flexible</em> with this content and other elements can be placed here, even icons.
<q2-icon type="search" inline></q2-search-icon>.
</div>
</q2-checkbox>
The q2-checkbox
element has one or more properties that support text localization. Those properties are indicated by the localizable badge in the description.
alignment
Determine which side of the label the checkbox will render on.
checked
The state of the checkbox. This modifies the visual appearance of the element.
description
Populates a description that is displayed beneath the label.
disabled
Disables the checkbox and prevents interaction.
hasError
has-error
Determines if the component should display in an errant state.
hideLabel
hide-label
Hide's the field's <label>
element from view.
Only use when a visible label is impractical.
indeterminate
Used on a parent checkbox in a checkbox group (e.g. "Select All") to indicate that some, but not all, checkboxes in a group are checked.
When true
, the "indeterminate" selection style is applied.
To apply the standard "checked" selection style, checked
must be true, and indeterminate
must be false
.
label
The visible label text for the checkbox. Appears to the right of the box for 'default' and 'favorite' checkboxes, and to the left for 'toggle' checkboxes. Yielded content will be adjacent to this text.
name
A static string used to establish a symbolic relationship between checkboxes.
readonly
The field is not interactive, but remains focusable.
slotReadonly
slot-readonly
The field is not interactive, but remains focusable.
type
The visual style of the checkbox. This does not need to be defined for a standard checkbox.
value
A static reference value for the checkbox.
The q2-checkbox
element exposes events that can be used to send and receive data from the component based on user interaction.
Emitted when the checkbox is toggled.
{ value: string; checked: boolean; }
If an event handler is bound to the element using:
onchange
property - The default handler will not fire, and the value must be updated in the custom handler.addEventListener("change")
method - The default handler will fire alongside the custom handler.This component uses other components in the Tecton library, including:
q2-icon
Other components in the Tecton library use this component, including:
q2-data-table
Add support for ellipcized labels
Initial Release
The following CSS variables are available to override the default theme styles of the q2-checkbox
component.
Many Tecton components consume other components to maintain visual and functional consistency. If you are looking for a CSS variable you think should exist but are not seeing it, it may be defined in one of the dependent components below. Either way, if you think it's something we should expose more conveniently, let us know!
There is 1 frequently asked question related to this page.