Skip to content

NumberInput

NumberInput provides a numeric input field with increment and decrement buttons. Use for quantities, scores, or any bounded numeric values.

QUANTITY
3

5
const [value, setValue] = useState(5);
<NumberInput
value={value}
onValueChange={setValue}
accessibilityLabel="Quantity"
/>

sm
3
md
3
lg
3
<NumberInput size="sm" value={value} onValueChange={setValue} accessibilityLabel="Small" />
<NumberInput size="md" value={value} onValueChange={setValue} accessibilityLabel="Medium" />
<NumberInput size="lg" value={value} onValueChange={setValue} accessibilityLabel="Large" />

NUMBER OF COINS
3
<NumberInput
label="Number of Coins"
value={coins}
onValueChange={setCoins}
min={1}
max={6}
accessibilityLabel="Number of coins"
/>

RATING (1-5)
1
<NumberInput
label="Rating (1-5)"
value={rating}
onValueChange={setRating}
min={1}
max={5}
accessibilityLabel="Rating"
/>

AMOUNT (STEP: 10)
50
<NumberInput
label="Amount (step: 10)"
value={amount}
onValueChange={setAmount}
step={10}
min={0}
max={100}
accessibilityLabel="Amount"
/>

LOCKED VALUE
6
<NumberInput
label="Locked Value"
value={6}
onValueChange={() => {}}
disabled
accessibilityLabel="Locked value"
/>

PropTypeDefaultDescription
valuenumberRequiredCurrent value
onValueChange(value: number) => voidRequiredChange handler
minnumber0Minimum value
maxnumberInfinityMaximum value
stepnumber1Step increment
size'sm' | 'md' | 'lg''md'Input size
disabledbooleanfalseDisabled state
labelstring-Label above input
styleViewStyle-Custom styles
accessibilityLabelstringRequiredScreen reader label

import { NumberInput, Card, Button, Text } from '@synchronicity/react-native';
import { View, StyleSheet } from 'react-native';
import { useState } from 'react';
function CoinCastingSetup() {
const [coinCount, setCoinCount] = useState(3);
const [throwCount, setThrowCount] = useState(6);
const [speed, setSpeed] = useState(50);
const handleStartCasting = () => {
startCasting({
coins: coinCount,
throws: throwCount,
animationSpeed: speed,
});
};
return (
<View style={styles.container}>
<Card style={styles.card}>
<Text style={styles.title}>Casting Settings</Text>
<View style={styles.inputGroup}>
<NumberInput
label="Number of Coins"
value={coinCount}
onValueChange={setCoinCount}
min={1}
max={6}
accessibilityLabel="Number of coins to throw"
/>
</View>
<View style={styles.inputGroup}>
<NumberInput
label="Number of Throws"
value={throwCount}
onValueChange={setThrowCount}
min={1}
max={12}
accessibilityLabel="Number of throws"
/>
</View>
<View style={styles.inputGroup}>
<NumberInput
label="Animation Speed"
value={speed}
onValueChange={setSpeed}
min={10}
max={100}
step={10}
accessibilityLabel="Animation speed percentage"
/>
</View>
<Button onPress={handleStartCasting}>
Start Casting
</Button>
</Card>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 16,
},
card: {
padding: 20,
},
title: {
fontSize: 18,
fontWeight: '600',
marginBottom: 24,
},
inputGroup: {
marginBottom: 20,
},
});