Components

Number Field

Spinbutton number input with increment and decrement controls.

NumberField is an unstyled spinbutton control. It combines a native number input with increment/decrement buttons, optional scrub area, wheel and keyboard stepping, min/max/step constraints, cancelable changes, commit events, and Field integration.

Use it for exact numeric input. For approximate values over a range, use Slider. For read-only values, use Meter.

Anatomy

  • #scrub: Custom content for the optional drag scrub area.
  • #decrement: Content inside the decrement button.
  • #increment: Content inside the increment button.

The native type="number" input is generated by the component and owns keyboard, form, and role="spinbutton" behavior. Style it with ui.input.

Usage

Value: 3

Examples

Min, max, and step

Use min, max, and step for button, keyboard, wheel, and input normalization.

<script setup lang="ts">
import { ref } from "vue";
import { NumberField } from "akaza-ui";

const seats = ref<number | null>(3);
</script>

<template>
  <NumberField v-model="seats" :min="1" :max="10" :step="1" />
</template>

Decimal values

Decimals work with step. By default, values snap to the nearest step.

<template>
  <NumberField v-model="ratio" :min="0" :max="1" :step="0.05" />
</template>

Scrub area

Add scrub-label or #scrub to let pointer users drag horizontally to change the value.

<template>
  <NumberField v-model="amount" scrub-label="Drag" :min="0" :max="100" />
</template>

Change vs commit

value-change fires before every accepted value update. value-commit fires after completed interactions such as blur, button click, wheel step, keyboard step, or scrub release.

<template>
  <NumberField
    v-model="quantity"
    @value-change="(value) => draft = value"
    @value-commit="(value) => save(value)"
  />
</template>

Field integration

NumberField inherits metadata from Field, including name, required, invalid state, and described-by ids. Native invalid state from required/min/max/step constraints is revealed after input, blur, or invalid submit; it is not shown on initial render.

<template>
  <Field label="CPU cores" name="cpu" required>
    <NumberField v-model="cpu" :min="1" :max="16" />
  </Field>
</template>

API Reference

Props

PropTypeDefaultDescription
idstringfield idInput id.
namestringfield nameForm field name.
minnumberMinimum value.
maxnumberMaximum value.
stepnumber1Increment/decrement step.
placeholderstringNative 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.
scrubLabelstringRenders a drag scrub area before the decrement button.
scrubStepnumberstepStep used by scrub dragging.
disableScrubbooleanfalseDisables scrub dragging.
getValueLabel(value) => string | undefinedHuman-readable aria-valuetext.
ariaLabelstringAccessible label when no visible label exists.
ariaDescribedbystringfield description/errorAccessible description ids.
uiNumberFieldUiClasses for structural parts.

Emits

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.

Slots

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

UI Options

KeyDescription
rootRoot wrapper.
scrubAreaOptional drag scrub area.
decrementDecrement button.
inputNative number input.
incrementIncrement button.

Styling Hooks

UI keyCSS classData attrs
rootakaza-number-fielddata-akaza-disabled, data-akaza-readonly, data-akaza-invalid, data-akaza-dirty, data-akaza-touched, data-akaza-filled, data-akaza-focused, data-akaza-scrubbing
scrubAreaakaza-number-field-scrub-areasame state attrs
decrementakaza-number-field-decrementsame state attrs
inputakaza-number-field-inputsame state attrs plus native validity attrs
incrementakaza-number-field-incrementsame state attrs

Plain class applies to the root wrapper. Use ui.input for the actual input.

Native data-akaza-invalid appears after interaction or invalid submit. Controlled invalid state from the invalid prop or parent Field appears immediately.

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.