Skip to content
LoidoltTheme 0.11.1
Svelte 5

Component

NumberField

A number input with clamped spin buttons.

import { NumberField } from '@loidolt/theme-svelte';

Example

Value: 12

Value: not set

Notes

  • Clearing the field cannot wedge it: an empty value clamps back to min, or to zero when unbounded.
  • At a bound the spin button goes aria-disabled rather than disabled, so it keeps focus instead of dropping it.
  • nullable lets the field be empty: clearing it yields null instead of the low bound. Type the bound variable as number | null.
  • readonly locks the steppers too; hideSteppers drops them for dense tables. The arrow keys still step.

Props

Generated from the component source, so it cannot drift from the implementation.

NumberField props
PropTypeDefaultNotes
label required string—Accessible name of the field; also used to name the two spin buttons.
boxed booleanfalseDraws the full box instead of the default underline.
class string—class lands on the wrapper; use inputClass to reach the input.
decrementLabel (label: string) => string(name) => `Decrease ${name}`
hideSteppers booleanfalseHide the − and + buttons, for dense tables. The keyboard still steps with the arrows.
incrementLabel (label: string) => string(name) => `Increase ${name}`
inputClass string—
max numberInfinity
min number-Infinity
nullable booleanfalseLet the field be empty: clearing it yields null instead of snapping to the low bound. For optional quantities where "not set" differs from zero. Type value as number | null to bind it.
onValueChange (value: V) => void—
ref bindableHTMLInputElement | nullnull
step number1
value bindableV0 as VA number, or null for an empty field when nullable is set.

Plus the attributes of Omit<HTMLInputAttributes, 'type' | 'value' | 'min' | 'max' | 'step'>, forwarded to the root element.