Skip to content

<XrCheckbox> ​

A checkbox with a label. The whole row is the target, at least the theme's minTarget tall, and it reacts to every input: mouse, controller ray, pinch and fingertip.

Usage ​

vue
<script setup lang="ts">
const agree = ref(false)
</script>

<template>
  <XrCheckbox v-model="agree">I agree to the terms</XrCheckbox>
  <XrCheckbox v-model="agree" label="Same, with a prop" disabled />
</template>

A press flips modelValue and emits update:modelValue and change.

Indeterminate ​

indeterminate draws a dash instead of the check mark, for a parent of several checkboxes that are only partly checked. A press on it emits true. The component never clears indeterminate by itself: compute it from the children, as in the demo above.

vue
<XrCheckbox :model-value="all" :indeterminate="some && !all" @update:model-value="setAll">All rooms</XrCheckbox>

For one choice out of several, use XrRadioGroup; for an on/off setting that applies at once, XrToggle.

API ​

Props ​

PropTypeDefaultDescription
uiRecord<string, unknown>{}Escape hatch: raw uikit (@pmndrs/uikit) properties for the row, merged last.
disabledbooleanGreys it out; it does not react to any input.
partsPartial<Record<"label" | "mark" | "box", Record<string, unknown>>>Raw uikit properties per inner part, merged after the defaults: box, mark (the check or dash), label.
modelValuebooleanChecked or not. Use with v-model.
indeterminatebooleanShows a dash instead of the check mark, whatever modelValue is. Clear it yourself on change.
labelstringText next to the box. The default slot replaces it.

Events ​

EventPayloadDescription
changevalue: boolean, event: ControlPointerEventPressed: the new state and the pointer event.
update:modelValuevalue: booleanThe new state after a press (v-model).

MIT License