
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-native-controlled-input
Advanced tools
A controlled React Native input that lets you format and constrain the value exactly how you want in JS, while keeping the displayed text in sync without invalid characters flashing in the field.
With a regular controlled TextInput, native input is applied first, then JS receives the change, filters it, and sends the next value back.
That means invalid characters can still flash in the field for a moment.
react-native-controlled-input is built for this exact case: you decide what text is valid, and the displayed value stays driven by value.
npm install react-native-controlled-input
Requires React Native New Architecture / Fabric.
import { useRef, useState } from 'react';
import { StyleSheet } from 'react-native';
import {
ControlledInputView,
type ControlledInputViewRef,
} from 'react-native-controlled-input';
export function Example() {
const [value, setValue] = useState('');
const inputRef = useRef<ControlledInputViewRef>(null);
return (
<ControlledInputView
ref={inputRef}
value={value}
onTextChange={(text) => setValue(text.replace(/\d/g, ''))}
style={styles.input}
onFocus={() => {}}
onBlur={() => {}}
/>
);
}
const styles = StyleSheet.create({
input: {
height: 48,
borderWidth: 1,
borderColor: '#ccc',
borderRadius: 8,
paddingHorizontal: 12,
fontSize: 16,
color: '#111',
},
});
inputRef.current?.focus();
inputRef.current?.blur();
| Prop | Type | Description |
|---|---|---|
value | string | Current input value. |
onTextChange | (value: string) => void | Called with the next text value. Filter it and update value. |
onFocus | () => void | Called when the text input is focused. |
onBlur | () => void | Called when the text input is blurred. |
autoComplete | string | Specifies autocomplete hints for the system. Same as React Native TextInput. |
autoCapitalize | string | Can be none, sentences, words, characters. Same as React Native TextInput. |
keyboardType | string | Determines which keyboard to open, e.g. numeric. Same as React Native TextInput. |
returnKeyType | string | Determines how the return key should look. Same as React Native TextInput. |
placeholder | string | The string that will be rendered before text input has been entered. |
placeholderTextColor | ColorValue | The text color of the placeholder string. |
selectionColor | ColorValue | The highlight and cursor color of the text input. |
The same style API is supported on both iOS and Android.
Commonly used supported styles:
color, fontSize, fontFamilypadding, paddingVertical, paddingHorizontalpaddingTop, paddingBottom, paddingLeft, paddingRight, paddingStart, paddingEndborderWidth, borderRadius, borderColor, backgroundColorwidth, height, margin, flexImplementation differs internally between platforms, but usage is the same for library consumers.
focus()blur()MIT
Made with create-react-native-library
FAQs
React Native Controlled Inputative Controlled Input
We found that react-native-controlled-input demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.