Skip to content

NumberInput

A number input field with optional slider, percent mode, and validation.

Examples

Basic

vue
<script setup>
import { ref } from "vue";
const days = ref(10);
</script>

<NumberInput v-model="days" label="Days" placeholder="Number of days" />

With hint and validation

vue
<NumberInput
  v-model="population"
  label="Population"
  hint="Total number of individuals"
  :min="1000"
  :max="100000"
  :step="1"
/>

Percent mode

vue
<NumberInput v-model="coverage" label="Vaccination coverage" percent :max="1" />

Slider

vue
<NumberInput
  v-model="r0"
  label="R0"
  hint="Basic reproduction number"
  :step="0.1"
  :min="1"
  :max="18"
  slider
/>

Live slider

With live, the model updates while dragging the slider thumb rather than only on release.

vue
<NumberInput
  v-model="coverage"
  label="Vaccination coverage"
  percent
  slider
  live
  :max="1"
/>

Live input

With live on a regular input, the model updates as you type (debounced 300ms). Arrow keys and spinner buttons commit immediately.

vue
<NumberInput v-model="days" label="Days" live />

Integer type

With number-type="integer", decimal values are truncated to whole numbers on commit. When combined with percent, the display value (e.g. 42%) is treated as the integer — so internal values like 0.42 are valid.

vue
<NumberInput v-model="days" label="Steps" number-type="integer" />

Hidden label

Use hide-label to visually hide the label while keeping it available to screen readers. Useful when a heading or surrounding context already describes the input visually.

vue
<NumberInput v-model="days" label="Days" hide-label />

Model

NameType
v-modelnumber

Props

PropTypeRequiredDefault
labelstringNo
hideLabelbooleanNo
placeholderstringNo
stepnumberNo
minnumberNo
maxnumberNo
hintstringNo
percentbooleanNo
sliderbooleanNo
livebooleanNo
numberType"integer" | "float"No