createNumberField API
Related
Explore these related pages for additional context and usage patterns.
| Page | Category |
|---|---|
| createNumberField | Forms |
| Number Field | Forms |
| createNumeric | Forms |
| createInput | Forms |
Functions
createNumberField
(options?: NumberFieldOptions) => NumberFieldContextOptions
commitOn
"input" | "change" | undefinedWhen to write typed input into value. 'change' (default) only
writes on commit() (blur/Enter). 'input' also writes on every
keystroke via write(), without clamping or snapping — clamping
mid-type would jump a value like 1 to min before the user finishes
typing 15. Clamping/snapping still happens on the next commit().
Default: 'change'
formNamespace
string | undefinedForm injection key. Must match the parent Form's namespace.
Default: 'v0:form'
required
boolean | undefinedWhether required. When true, a presence rule is registered so Form
submit fails on empty values even with novalidate.
rules
(string | import("/home/runner/work/0/0/packages/0/src/composables/createForm/index").FormValidationRule | import("/home/runner/work/0/0/packages/0/src/composables/useRules/index").StandardSchemaV1)[] | undefinedValidation rules.
errorMessages
MaybeRefOrGetter<import("/home/runner/work/0/0/packages/0/src/types/index").MaybeArray<string> | undefined>Manual error messages — merged with rule-based errors.
Properties
commitOn
"input" | "change"When typed input is written into value — see {@link NumberFieldOptions.commitOn}.
Methods
commit
(next?: number | null) => voidSnap and optionally clamp the current value. Pass next to avoid reading the stale model on the same tick as a write.
write
(text: string) => voidParse text and write it straight into value, without clamping or
snapping. Used by commitOn: 'input' consumers to get per-keystroke
updates without the min/max jump commit() would cause mid-type.