Skip to content

Number Field

Enter a number or adjust it with increment and decrement buttons.

Demos

Size
Variant

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy NumberField.vue and index.ts into app/components/ui/number-field/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm
variantoutline, soft, bareoutline

Props

PropTypeDefaultDescription
idstringfield idInput id.
namestringfield nameForm field name.
minnumber—Minimum value.
maxnumber—Maximum value.
stepnumber1Increment/decrement step.
placeholderstring—Native input placeholder.
requiredbooleanfalseRequired state.
disabledbooleanfalseDisabled state.
readonlybooleanfalseRead-only state.
invalidbooleanfalseSets invalid attrs.
stepSnappingbooleantrueSnap input/button values to the nearest step.
disableWheelChangebooleanfalseDisables focused wheel stepping.
invertWheelChangebooleanfalseReverses wheel direction.
focusOnChangebooleantrueFocuses the input after button/scrub changes.
scrubLabelstring—Renders a drag scrub area before the decrement button.
scrubStepnumberstepStep used by scrub dragging.
disableScrubbooleanfalseDisables scrub dragging.
getValueLabel(value) => string | undefined—Human-readable aria-valuetext.
ariaLabelstring—Accessible label when no visible label exists.
ariaDescribedbystringfield description/errorAccessible description ids.
uiNumberFieldUi—Classes for structural parts.

Slots

SlotPropsDescription
scrubvalue, isScrubbingCustom scrub area content.
decrementvalue, decrementCustom decrement button content.
incrementvalue, incrementCustom increment button content.

Events

EventPayloadDescription
value-change(value, details)Fired before model updates. details.cancel() prevents the update.
value-commit(value, details)Fired on blur and after button, wheel, keyboard, or scrub interactions.

Keyboard

KeyBehavior
ArrowUp / ArrowDownIncrement/decrement by step.
PageUp / PageDownIncrement/decrement by step * 10.
HomeSet to min when provided.
EndSet to max when provided.

Mouse wheel changes the value only while the input is focused. Set disableWheelChange to opt out.