Skip to content

FormNumber

Typed numeric input with stepper buttons, built on Reka UI's NumberField primitive. Locale-aware via Intl.NumberFormatOptions, snap-to-step, and proper min / max bounds. Cleaner than <input type="number"> and consistent across browsers.

bash
npm install @vuecs/forms

Basic usage

vue
<script setup lang="ts">
import { VCFormNumber } from '@vuecs/forms';
import { ref } from 'vue';

const quantity = ref<number>(1);
const price = ref<number>(19.99);
</script>

<template>
    <VCFormNumber v-model="quantity" :min="0" :max="99" :step="1" />

    <VCFormNumber
        v-model="price"
        :min="0"
        :step="0.01"
        :format-options="{ style: 'currency', currency: 'USD' }"
    />
</template>
css
@import "tailwindcss";
@import "@vuecs/design";

@import "@vuecs/forms";

@custom-variant dark (&:where(.dark, .dark *));

Locale + currency formatting

format-options is forwarded to Intl.NumberFormat. Anything that constructor accepts works — style: 'currency', style: 'percent', maximumFractionDigits, etc. The locale prop overrides the document locale:

vue
<VCFormNumber
    v-model="amount"
    :format-options="{ style: 'currency', currency: 'EUR' }"
    locale="de-DE"
/>

Props

PropTypeDefaultDescription
modelValuenumber | nullundefinedBound value
minnumberundefinedLower bound (inclusive)
maxnumberundefinedUpper bound (inclusive)
stepnumber1Increment per stepper click / arrow-key press
stepSnappingbooleantrueSnap typed values to the nearest step
focusOnChangebooleanfalseRe-focus the input after stepper-driven changes
formatOptionsIntl.NumberFormatOptionsundefinedDisplay + parsing format
localestringundefinedBCP-47 locale for formatting
steppersbooleantrueRender the ± stepper buttons
disabledbooleanfalseDisable interaction
requiredbooleanfalseForm-required attribute
namestringundefinedForm-submission name
idstringundefinedRoot id
themeClassPartial<FormNumberThemeClasses>undefinedPer-instance theme override
themeVariantRecord<string, string | boolean>undefinedPer-instance variant values

Events

EventPayloadDescription
update:modelValuenumberEmitted on user input or stepper click

Released under the Apache 2.0 License.