React native textInput only numbers tablet

133 Views Asked by At

enter image description here

I would need that when I click on the input field, only the numeric keyboard comes out.

On smartphones. it works, but trying on the tablet the numeric keyboard comes out as default but gives the user the possibility to be able to change with the letters.

Is there a way to make user unable to change.

import { View, StyleSheet, TextInput } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
      <TextInput placeholder="useless placeholder" keyboardType="numeric" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: 46,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
});

1

There are 1 best solutions below

2
Nani On

You can refer the keyboard type here

Have u tried keyboardType="number-pad"?