Skip to content

Number Input

@astryxdesign/core v0.7.1 · NumberInput

Usage ​

NumberInput is a numeric field. People type a number; add hasNumberSteppers when they should also get up and down chevrons. min and max clamp the value, and step sets how much each click changes it.

Bind a number:

vue
<script setup lang="ts">
import { NumberInput } from '@astryx-vue/core/NumberInput'
import { ref } from 'vue'

const count = ref(0)
</script>

<template>
  <NumberInput v-model="count" :min="0" :max="100" />
</template>

Values outside min and max are pulled back into range. The stepper names are English unless the app calls provideAstryxLocale('zh-CN'). When label is set, it is included in those names.

Three props adjust the field to the number it holds. isIntegerOnly keeps decimals out of the committed value. formatValue shows a readable form while the field is idle, such as 1,234 items, and switches back to the raw number on focus. isWheelEnabled={false} stops the wheel from stepping the value where page scrolling matters more.

Anatomy

ElementDescription
LabelThe label for the number input.
DescriptionAdditional description text below the label.
IconAn optional icon within the input.
PlaceholderPlaceholder text shown when the input is empty.
Number steppersOptional buttons that increment or decrement by the configured step.

Best practices ​

GuidelinePractice
DoSet min and max when the value has a real range.
DoPick a step that matches the field: 1 for a count, 0.01 for a price.
DoPut the unit in the label, such as "Quantity (pcs)", rather than inside the field.
Don'tUse a tiny step across a wide range. People will have to click the stepper many times.

Examples ​

Clearable

%

Progress from 0 to 100, with a percent suffix and a clear button.

Range

Number of people on the team

Team size from 1 to 50, with a description of what the number means.

Status

Must be a positive amount
Exceeds typical team size
%
On track

Error, warning, and success on budget, headcount, and completion.

Units

%

A discount with a percent suffix, limited to 0–100.