<XrNumberInput>
A number with − and + buttons and a field to type it in. The buttons work with every input (mouse, controller ray, pinch, fingertip) and keep stepping while held.
Usage
vue
<script setup lang="ts">
const guests = ref(2)
const temperature = ref(21.5)
</script>
<template>
<XrNumberInput v-model="guests" :min="1" :max="12" />
<XrNumberInput v-model="temperature" :min="16" :max="28" :step="0.5" suffix="°C" />
</template>min/maxbound the value; − is disabled atminand + atmax.stepis what − and + add;precision(decimals kept) defaults to the decimals ofstep, sostep="0.5"keeps one.suffixis a muted unit after the field.- Without a value (
undefined), the field showsplaceholderand the first − or + setsmin(or 0).
Stepping and typing
− and + step once on release, like every vue-xr-ui control. Held for about half a second, they step again ten times a second until released or a limit is reached.
The field is an XrTextField: type with an XrKeyboard, a physical keyboard, or the Quest's system keyboard. The typed text becomes the value on Enter or when the field loses focus: parsed (a comma works as the decimal point), clamped to min..max and rounded to precision. Text that is not a number puts the previous value back.
update:modelValue and change carry a value that is always inside the limits.
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; nothing reacts. | |
parts | Partial<Record<"decrement" | "increment" | "field" | "suffix", Record<string, unknown>>> | Raw uikit properties per inner part, merged after the defaults: decrement, increment (the buttons), field, suffix. | |
min | number | Number.NEGATIVE_INFINITY | Smallest value; − is disabled there. |
max | number | Number.POSITIVE_INFINITY | Largest value; + is disabled there. |
step | number | 1 | How much − and + change the value. |
suffix | string | Text after the field, such as a unit (%, °C). | |
precision | number | Decimals to keep. Defaults to the decimals of step. | |
modelValue | number | The value. Use with v-model. | |
placeholder | string | Shown, muted, while there is no value. |
Events
| Event | Payload | Description |
|---|---|---|
change | value: number | Same as update:modelValue, only when the value differs from the current one. |
update:modelValue | value: number | A new value from −, + or the field (v-model). Always within min..max. |