Skip to content

GhostNumberInput ​

GhostNumberInput is a locale-aware numeric spinbutton with v-model, min / max / step, increment and decrement buttons, and clamping. Import it from @ghostvue/themes for the default visual treatment. To style the parts yourself, see Advanced: headless composition.

Plan & quota limits

Bounded, currency-formatted, and disabled GhostNumberInput controls with live total.

Plan & quota limits

Adjust team seats and monthly spend caps. Estimated seat cost: $288 / month.

The quota form pairs themed GhostNumberInput from @ghostvue/themes with GhostField: active seats clamp between 1 and 50, the spend cap formats as USD currency in $50 steps, and the disabled legacy quota scales its stepper buttons at size="sm".

Bounds and units ​

Workshop booking

Seat and session-length limits with unit-formatted values, disabled steppers at the bound, and a limit message.

Book a design workshop

$30 per seat per hour. Seats and length stop at their limits.

min and max are inclusive and set aria-valuemin / aria-valuemax. At a bound, the stepper button for that direction disables and the arrow keys stop. Home and End jump straight to min and max, and a typed value outside the range clamps on blur. Because the disabled button is the only visual cue, the booking card also says in words which limit was reached.

Session length formats with { style: 'unit', unit: 'minute', unitDisplay: 'long' }, so the field reads "90 minutes" and so does aria-valuetext. Seats need no unit: the label already says what the number counts.

Size and layout ​

Themed

Large block retry delay in seconds from @ghostvue/themes.

size scales the field and its stepper buttons, and block stretches the control to the width of its container. Without block, the control fits about eight digits in a toolbar or table cell and fills a GhostField; see form control widths. class and style go to a frame around the whole control, so an inline-size there sizes the field and its buttons together. Other attributes, such as id, name and aria-*, still reach the text input. The retry delay formats in seconds and names its buttons for the action they take.

@ghostvue/themes adds these to the headless GhostNumberInput API, which it forwards:

PropTypeDefaultDescription
size'sm' | 'md' | 'lg'"md"Control size. Default omits data-size.
blockbooleanfalseFill the container's inline size via data-block. Without it the control fits about eight digits and fills a GhostField.

Field integration ​

Bind the GhostFieldControl slot props to the spinbutton with v-bind, as the examples above do, so the field's label, description and invalid state reach the spinbutton itself rather than the stepper buttons.

Committing values ​

v-model emits update:modelValue when a value commits (blur after typing, Enter, buttons, or keyboard stepping). While typing, the draft text is local until commit.

Locale and format parsing contract ​

GhostNumberInput formats and round-trip parses Intl.NumberFormat outputs for notation: 'standard' (the default) across decimal, currency (including currencySign: 'accounting'), percent, and unit styles:

  • Affixes and signs: Currency symbols/codes, unit labels, percent signs, accounting parentheses (...), signDisplay markers, and Unicode bidi control characters are stripped based on Intl.NumberFormat.formatToParts. Drafts with or without the configured currency/unit/percent affixes parse to the same numeric model value.
  • Percent scaling: In style: 'percent', both 60% and plain 60 commit to modelValue = 0.6 (and submit 0.6 via the hidden form input).
  • Localized digits: Both the locale's numberingSystem digits (such as Eastern Arabic-Indic ٠–٩ or Persian ۰–۹) and ASCII 0–9 are accepted.
  • Grouping: Locale group separators are optional, but when present they must match the locale's grouping sizes (for example, 1.234,5 is valid in de-DE, while malformed grouping like 1.5 in de-DE is rejected and reverts to the last committed value).
  • Non-standard notations: compact, scientific, and engineering notations are outside the editing contract and are not parsed.

To show a unit with the value, such as "30 seconds", use { style: 'unit', unit: 'second', unitDisplay: 'long' } rather than placing text beside the control. The formatted unit then appears in the field and in aria-valuetext. The input group recipe is for text inputs, not for GhostNumberInput.

Accessibility ​

Follows the WAI-ARIA spinbutton pattern. Arrow keys, Home, End, and Page Up/Down adjust the value while the spinbutton is focused. Tab targets the spinbutton only; buttons are pointer and programmatic accessories (tabindex="-1"). Give the buttons specific names with decrement-label and increment-label when a form has several spinbuttons.

Advanced: headless composition ​

For teams that bring their own design system, the headless GhostNumberInput from @ghostvue/vue renders the same spinbutton and buttons with no styles.

Basic use ​

Basic Headless

Labeled spinbutton with min, max, and step.

Current page size: 25

The spinbutton is a text field with role="spinbutton". Pair it with a visible label (or aria-label / aria-labelledby). Native attributes fall through to the text field, not the surrounding buttons.

Headless bounds ​

Bounds Headless

Increment buttons disable at min and max.

Increment and decrement disable at min and max. Typed values clamp on blur.

GhostField ​

Field Headless

Currency formatting inside GhostField.

Filter: none

Bind GhostFieldControl slot props to the spinbutton input through v-bind.

Component refs ​

Component ref Headless

Programmatic increment through the exposed API.

Score: 10

The ref exposes element, focus, blur, increment, and decrement.

Styling hooks ​

  • Root: ghost-number-input, data-part="root", optional data-state
  • Input: ghost-number-input__input, data-part="input"
  • Buttons: ghost-number-input__button, data-part="decrement" | "increment"

API ​

PropTypeDefaultDescription
decrementLabelstring"Decrease"aria-label on the decrement button.
defaultValuenull | numbernullInitial uncontrolled value and form-reset seed.
disabledbooleanfalseDisables the field and buttons.
formatOptionsIntl.NumberFormatOptions—Display and round-trip parse options (notation: 'standard').
incrementLabelstring"Increase"aria-label on the increment button.
invalidbooleanfalseSets aria-invalid on the spinbutton.
localestring—Intl.NumberFormat locale.
maxnumber—Inclusive maximum (aria-valuemax).
minnumber—Inclusive minimum (aria-valuemin).
modelValuenull | number—Controlled value. Omit for uncontrolled mode. null is empty.
readonlybooleanfalseFocusable; edits and buttons do not change the value.
requiredbooleanfalseNative required on the spinbutton.
stepnumber1Step for buttons and arrow keys.