dssoca docs
GitHub repository

NumberField

Numeric input with steppers.

A numeric text field built on a native `<input type="number">` with monospace value display and a pair of − / + stepper buttons. Steppers increment/decrement by `step`, clamp to `min`/`max`, and disable at their bound. Clearing the field yields `null`. Mirrors the Input chrome — label, hint/error text, focus ring on the wrapper, and `aria-describedby` ordering (error → hint → describedby).

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { NumberField } from 'dssoca';
  let replicas = $state(3);
</script>

<NumberField label="Replicas" bind:value={replicas} min={0} max={10} />

WCAG 2.2 AA. The native spinner is hidden in favour of accessible − / + buttons labelled "Decrease" / "Increase"; each is disabled at its bound or when the field is disabled/readonly. The value is rendered monospace.

Props

PropTypeDefaultDescription
labelstringLabel text associated to the input via for/id.
valuenumber | nullBindable current value; `null` when empty.
minnumberLower bound; clamps the steppers and disables − at the floor.
maxnumberUpper bound; clamps the steppers and disables + at the ceiling.
stepnumber1Increment/decrement applied by the steppers.
namestringNative form field name.
placeholderstringPlaceholder shown when the field is empty.
requiredbooleanfalseMarks the field required; renders a label marker.
disabledbooleanfalseDisables the input and both steppers.
readonlybooleanfalseValue visible but not editable; steppers inert.
invalidbooleanMarks the field invalid for assistive tech (aria-invalid).
hintstringHelper text under the field, wired via aria-describedby.
errorstringError text; implies aria-invalid and is announced via role="alert".
describedbystringExtra aria-describedby id(s), appended after error/hint.
onchange(e: Event) => voidNative change handler fired when the committed value changes.
size'sm' | 'md' | 'lg'Per-instance size override; inherits the ancestor `data-size-variant` when unset.