Skip to content

Checkbox

A checkbox is an essential user interface component that enables users to make binary choices, such as selecting or deselecting options. It is commonly used for tasks like toggling settings, selecting multiple items, or confirming agreements within an application.

Example

Below is an example showcasing two checkbox components. The checkbox on the left is in its initial, unchecked state, while the one on the right displays a checked checkbox.

Props

PropertyTypeDefaultDescription
visiblebooleantrueControls the checkbox's visibility. When true, the checkbox is visible; when false, it is hidden.
sizeenum (small, medium, large, extra-large)mediumSets the checkbox's size, adjusting padding, font size, and layout compactness accordingly.
positionnumber[]0 0 0Specifies the checkbox's position.
primarystring (blue, #fff)#00BA92Defines the primary color of the checkbox (affecting text, background, icon background).
valuebooleanfalseSpecifies whether the checkbox is checked.
variantstring (light, dark)""Sets the button's color scheme mode, either "light" or "dark," for visual theme consistency.

Events

The checkbox component emits the following event when interacted with:

EventParametersDescription
value-changed{ value: boolean }Emitted when the checkbox is toggled. Returns the new checked state.

Note

You can listen to the value-changed event to react whenever the checkbox state changes.

js
el.addEventListener("value-changed", (event) => {
  console.log(event.detail.value);
});