NumberInput
A native number input with the Viam border and padding. It renders one <input type="number">, so
class lands on it and the consumer owns its width. Inside a Field it
takes its id (the field’s controlId), disabled, required, state, and aria-describedby from there. Inside an
Input.Group it goes borderless.
<NumberInput id="qty" min={0} max={10} bind:value /><NumberInput
value={3}
min={0}
max={10}
step={1}
state="none"
/>- Its own native
<input type="number">. It takes the samestateasInputand works inside anInput.Groupwith aField.StateIcon. valueisnumber | undefined. No string parsing on your side.min,max, andstepare the native attributes. The browser owns stepping, spin buttons, and the wheel.
Two-way binding
Section titled “Two-way binding”Clear the field and the value becomes undefined.
value: 3
Code
<script lang="ts"> import { Field, Hint, Label, NumberInput } from "@viamrobotics/prime-ui";
let count = $state<number | undefined>(3);</script>
<div class="not-content"> <Field class="flex max-w-3xs flex-col gap-1"> <Label>Quantity</Label> <NumberInput bind:value={count} min={0} max={10} step={1} /> <Hint>Clear the field and the value becomes undefined.</Hint> </Field>
<p class="mt-3 text-sm text-subtle-2">value: <code>{count ?? "undefined"}</code></p></div>For the controlled mode, see State & binding.
States
Section titled “States”Error state, with Field.StateIcon
Disabled and read-only
Styling
Section titled “Styling”Same as Input: class lands on the <input>, and it carries no width. Inside an Input.Group the input goes borderless and the group carries the border. The input carries data-field-state and aria-invalid from state.
Keyboard
Section titled “Keyboard”Native number input behavior: ArrowUp and ArrowDown step by step within min and max. Nothing is added or intercepted.
| Prop | Type | Default | Description |
|---|---|---|---|
bind:value | number | Current value. An empty field is undefined. | |
min | number | The minimum allowed value. | |
max | number | The maximum allowed value. | |
step | number | 'any' | 1 | Step for keyboard or spin-button increments, and the granularity constraint validation
enforces. 'any' accepts every decimal, which no number can express. |
state | FieldState | Contextual state. Defaults to the enclosing field's state. |
Plus everything in Omit<
HTMLInputAttributes,
'value' | 'min' | 'max' | 'step' | 'type' | 'children'
>, spread onto the element.