React Native · Components
NumberInput
A field that accepts only numbers and is formatted in the language's style while typing (the same rules as NumberInput/NumberField on web, @yasinsensoy/core/number-format).
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Quantity picker: integer, 1–99, speeds up when held
Price: two fixed decimals, no minus
Percentage: show an error instead of clamping
Controlled usage
Value: 2500
Languages: same value, different separators
Import
NumberInput
componentA field that accepts only numbers and is formatted in the language's style while typing (the same rules as NumberInput/NumberField on web, @yasinsensoy/core/number-format).
- Thousands separators are added while typing (
1.234.567,89in Turkish); both,and.work for decimals; a pasted₺1.234,56turns into the right number. - On blur the value is clamped to the limits and the format is completed.
stepperadds − / + buttons (a 44 px touch area, accelerating when held).
Examples
parseNumber
functionParses number text the user typed or pasted. Currencies, spaces and letters are dropped; non-Latin digits are understood.
The decimal separator is found like this:
- If the text has both
.and,, the last one is the decimal (1.234,56,1,234.56). - If a single kind of separator appears more than once, it is the group separator (
1.000.000). - If it appears once: it is the decimal if it is the locale's decimal separator; otherwise it is the group separator when exactly three digits follow (
1.234→ 1234 intr-TR), else the decimal (12.5→ 12.5).
Examples
NumberInputProps
interfaceProps of NumberInput.
Extends: FieldProps, Omit<TextInputProps, "value" | "defaultValue" | "onChangeText" | "editable" | "style" | "keyboardType">
| Name | Type | Default | Description |
|---|---|---|---|
ref? | Ref<TextInputRef> | Ref of the underlying native element. | |
variant? | FieldVariant | "outline" | Appearance. See FieldVariant. |
value? | number | null | Value (controlled); null for an empty field. | |
defaultValue? | number | null | Initial value (uncontrolled). | |
onValueChange? | (value: number | null) => void | When the value changes; null for an empty field. | |
min? | number | Minimum value. At 0 or above the minus sign cannot be typed. | |
max? | number | Maximum value. | |
step? | number | 1 | Amount the step buttons change. |
decimals? | number | Maximum decimal places; 0 allows integers only (keyboard without decimals). | |
fixedDecimals? | boolean | false | Always show decimals with decimals places (12 → 12.00). |
grouping? | boolean | true | Thousands separator (1,234,567). |
clamp? | boolean | true | On blur, clamp a value outside min/max to the limit. |
stepper? | boolean | false | − and + buttons; holding repeats with acceleration. |
locale? | string | {@link UIProvider} `locale | Language of the separators. |
icon? | IconProp | Icon at the start of the box. | |
iconEnd? | IconProp | Icon at the end of the box. | |
prefix? | ReactNode | Short text before the number (e.g. "$"). Not part of the value. | |
suffix? | ReactNode | Unit after the number (e.g. "kg", "%"). Not part of the value. | |
readOnly? | boolean | Read-only. | |
style? | StyleProp<ViewStyle> | Style of the box. |