<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
| Prop | Type | Default | Description |
|---|---|---|---|
ui | Record<string, unknown> | {} | Escape hatch: raw uikit (@pmndrs/uikit) properties for the row, merged last. |
disabled | boolean | Greys it out; it does not react to any input. | |
parts | Partial<Record<"label" | "mark" | "box", Record<string, unknown>>> | Raw uikit properties per inner part, merged after the defaults: box, mark (the check or dash), label. | |
modelValue | boolean | Checked or not. Use with v-model. | |
indeterminate | boolean | Shows a dash instead of the check mark, whatever modelValue is. Clear it yourself on change. | |
label | string | Text next to the box. The default slot replaces it. |
Events
| Event | Payload | Description |
|---|---|---|
change | value: boolean, event: ControlPointerEvent | Pressed: the new state and the pointer event. |
update:modelValue | value: boolean | The new state after a press (v-model). |