Products · Components

Checkbox

A box the person ticks to agree or to choose an option.

For a setting that applies at once, use a Switch.

Children: Nothing

Example

The Checkbox component
view.dml
<Checkbox label="I agree to the terms" checked="{{ agreed }}" onChange="setAgreed" />
controller.ts
export default definePage({
  initialState: { agreed: false },
  mutations: {
    setAgreed: (_state, event: CheckedEvent) => ({ agreed: event.detail.checked }),
  },
});

Props

PropTypeWhat it is
checkedbooleanDefault: false.
labelstring
disabledbooleanDims it, and the person can't use it.

Events

EventSendsNotes
onChange{ checked } in detail

Keep reading

On this page