Skip to content
CodeAtlas UI

Inputs

NumberField

Stepper input for numeric values with optional min, max and step.

<script>
  import { NumberField } from "@codeatlasdev/ui";
  let qty = $state(1);
</script>

<NumberField label="Quantity" bind:value={qty} min={0} max={99} />

The plus and minus buttons stop at min and max. Typing a value does not clamp it, so validate on your side if a typed value can leave the range.

Basic

Integer and decimal steps with bounds.

Code
svelte
<script lang="ts">
  import { NumberField, Stack } from '@codeatlasdev/ui';

  let qty = $state(1);
  let price = $state(9.99);
</script>

<Stack gap={16}>
  <NumberField label="Quantity" bind:value={qty} min={0} max={99} />
  <NumberField label="Price" bind:value={price} min={0} step={0.01} />
</Stack>

States

Helper text, error, disabled and the small size.

Max 50 seats per plan.

Code
svelte
<script lang="ts">
  import { NumberField, Stack } from '@codeatlasdev/ui';

  let fixed = $state(5);
  let seats = $state(60);
</script>

<Stack gap={16}>
  <NumberField label="Seats" value={3} min={1} max={50} description="Max 50 seats per plan." />
  <NumberField label="Seats" bind:value={seats} min={1} max={50} error="Plans support up to 50 seats." required />
  <NumberField label="Fixed amount" bind:value={fixed} disabled />
  <NumberField label="Small" size="sm" value={2} />
</Stack>

Props

PropTypeDefaultDescription
valuenumber0Bindable numeric value.
minnumber–Minimum value. The decrement button disables at this value.
maxnumber–Maximum value. The increment button disables at this value.
stepnumber1Increment applied by the plus and minus buttons.
labelstring–Label text.
descriptionstring–Hint shown below the field.
errorstring–Error message. Puts the field in the error state.
requiredbooleanfalseMarks the field as required.
disabledbooleanfalseDisables the field and its buttons.
namestring–Native name, for form submission.
size'sm' | 'md''md'Field height.
classstring–Extra classes on the root.
onchange(value: number) => void–Called on every change, from the buttons or from typing a valid number.