Skip to main content

Checkbox Component

Figma

The glu-checkbox component is a composite checkbox that supports advanced states—unchecked, checked, and optionally indeterminate—and provides flexible labeling. You can display a label on the left and/or right of the checkbox, and include helper text or error messages below the checkbox. The component is designed to be fully accessible with proper ARIA attributes and keyboard interactions, and it emits a glChange event when the checkbox state is toggled.

Below are several examples that demonstrate the versatility of the checkbox component.


Basic Usage

Example 1: Basic Unchecked Checkbox

Result
Loading...
Live Editor
<glu-checkbox leftLabel="Accept Terms" value="unchecked"></glu-checkbox>

Checkbox with Right Label

Display a checkbox with a right-aligned label.

Result
Loading...
Live Editor
<glu-checkbox rightLabel="I Agree" value="unchecked"></glu-checkbox>

Checkbox with Both Left and Right Labels

Combine left and right labels for additional context.

Result
Loading...
Live Editor
<glu-checkbox leftLabel="Accept" rightLabel="Terms & Conditions" value="unchecked"></glu-checkbox>

Checkbox with Error and Helper Text

Display an error message with helper text when validation fails.

Result
Loading...
Live Editor
<glu-checkbox
  leftLabel="Subscribe"
  error="This field is required"
  helperText="Please check the box to subscribe"
  helperIcon="error-icon"
  value="unchecked"
></glu-checkbox>

Checkbox with Indeterminate State

When the hasIndeterminate property is enabled, the checkbox can toggle through an indeterminate state.

Result
Loading...
Live Editor
<glu-checkbox
  leftLabel="Select All"
  hasIndeterminate
  value="indeterminate"
></glu-checkbox>

Disabled Checkbox

Prevent user interaction by disabling the checkbox.

Result
Loading...
Live Editor
<glu-checkbox
  leftLabel="I Agree"
  disabled
  value="unchecked"
></glu-checkbox>

Properties

PropertyAttributeDescriptionTypeDefault
disableddisabledDisables the checkbox, preventing user interaction.booleanfalse
errorerrorThe error message to display. When non-empty, the component enters an error state.stringundefined
hasIndeterminatehas-indeterminateSpecifies whether the checkbox has an indeterminate state. If false (default), the checkbox toggles only between "unchecked" and "checked".booleanfalse
helperIconhelper-iconThe name of the helper icon displayed alongside the helper text. If an error exists, a default error icon is shown instead.stringundefined
helperIconVarianthelper-icon-variantSpecifies the visual variant for the helper icon. Allowed values: 'solid' or 'outline'."outline" | "solid"'outline'
helperTexthelper-textSupplemental helper text displayed below the input.stringundefined
leftLabelleft-labelOptional left label text displayed adjacent to the checkbox. Rendered using the glu-label component.stringundefined
rightLabelright-labelOptional right label text displayed adjacent to the checkbox. Rendered using the glu-label component.stringundefined
valuevalueThe current value (state) of the checkbox. Supported values: - 'unchecked' - 'checked' - 'indeterminate' This property is mutable to support two-way binding."checked" | "indeterminate" | "unchecked"'unchecked'

Events

EventDescriptionType
glChangeEmitted when the checkbox value changes.CustomEvent<{ value: "checked" | "unchecked" | "indeterminate"; event: Event; }>

Dependencies

Depends on

Graph


Built with StencilJS