Forms Core Stable

NumberInput

Numeric field with decrement/increment buttons that clamp to min/max, disable themselves at the bounds, and step fractional values without float drift

Preview

Installation

pnpm add fancy-ui-svelte
import { NumberInput } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { NumberInput } from 'fancy-ui-svelte';
</script>

<NumberInput />

Examples

Basic Usage

With Limits

Bounded 1–8 with the buttons disabling at the edges.

Fractional Steps

0.1 steps over a 0–1 range, without float drift.

Props

PropTypeDefaultDescription
value number | nullnullCurrent value; bindable. null when the field is empty
onValueChange (value: number | null) => void-Called with the new value on every change, including a clear to null
min number-Lower bound. Leave unset for no lower bound
max number-Upper bound. Leave unset for no upper bound
step number1Increment size, including fractional steps
disabled booleanfalseBlocks focus, typing and the step buttons; excluded from form submission. Overridden by a surrounding FormField
readonly booleanfalseBlocks typing and the step buttons but stays focusable and is still submitted, unlike disabled
required booleanfalseNative required. Overridden by a surrounding FormField
invalid booleanfalseDrives the error border and aria-invalid. Overridden by a surrounding FormField
id string-Element id. Overridden by a surrounding FormField's own controlId
name string-Native name, read on form submission
label string-Accessible name — for a control with no visible Label next to it
class string-Additional CSS classes, applied to the outer bordered wrapper
ref HTMLInputElement | nullnullReference to the underlying input type=number