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-disabledrather thandisabled, so it keeps focus instead of dropping it. nullablelets the field be empty: clearing it yieldsnullinstead of the low bound. Type the bound variable asnumber | null.readonlylocks the steppers too;hideSteppersdrops them for dense tables. The arrow keys still step.
Props
Generated from the component source, so it cannot drift from the implementation.
| Prop | Type | Default | Notes |
|---|---|---|---|
label required | string | — | Accessible name of the field; also used to name the two spin buttons. |
boxed | boolean | false | Draws 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 | boolean | false | Hide the − and + buttons, for dense tables. The keyboard still steps with the arrows. |
incrementLabel | (label: string) => string | (name) => `Increase ${name}` | |
inputClass | string | — | |
max | number | Infinity | |
min | number | -Infinity | |
nullable | boolean | false | Let 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 bindable | HTMLInputElement | null | null | |
step | number | 1 | |
value bindable | V | 0 as V | A 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.