TextField
An enhanced customizable TextField with validation support
(code example)
This component extends TextInput props.
This component support margin, color, typography modifiers.
Usageβ
<TextField placeholder={'Placeholder'} floatingPlaceholder onChangeText={text => console.log(text)} enableErrors validateOnChange validate={['required', (value) => value.length > 6]} validationMessage={['Field is required', 'Password is too short']} showCharCounter maxLength={30} />
APIβ
centeredβ
Whether to center the TextField - container and label
boolean
charCounterStyleβ
Pass custom style to character counter text
TextStyle
colorβ
Input color
ColorType
containerPropsβ
Container props of the whole component
Omit<ViewProps, 'style'>
containerStyleβ
Container style of the whole component
ViewStyle
enableErrorsβ
Should support showing validation error message
boolean
fieldStyleβ
Internal style for the field container to style the field underline, outline and fill color
ViewStyle | (context: FieldContextType, props) => ViewStyle
floatOnFocusβ
Should placeholder float on focus or when start typing
boolean
floatingPlaceholderβ
Pass to add floating placeholder support
boolean
floatingPlaceholderColorβ
The floating placeholder color
ColorType
floatingPlaceholderStyleβ
Custom style for the floating placeholder
TextStyle
formatterβ
Custom formatter for the input value (used only when input if not focused)
(value) => string | undefined
helperTextβ
Text to display under the input
string
hintβ
A hint text to display when focusing the field
string
innerFlexBehaviorβ
This may cause flex issues when the field is inside a row containerβ
Set the inner container to use flex behavior to resolve text overflow issues when using leading or trailing accessories
boolean
labelβ
Field label
string
labelColorβ
Field label color. Either a string or color by state map ({default, focus, error, disabled, readonly})
ColorType
labelPropsβ
Pass extra props to the label Text element
TextProps
labelStyleβ
Custom style for the field label
TextStyle
leadingAccessoryβ
Pass to render a leading element
ReactElement
onChangeValidityβ
Callback for when field validity has changed
(isValid: boolean) => void
onClearβ
On clear button callback
() => void
onValidationFailedβ
Callback for when field validated and failed
(failedValidatorIndex: number) => void
placeholderβ
The placeholder for the field
string
placeholderTextColorβ
Placeholder text color
ColorType
presetβ
Predefined preset to use for styling the field
Presets |
${Presets}| null | string
readonlyβ
A UI preset for read only state
boolean
recorderTagβ
Recorder Tag
'mask' | 'unmask'
retainValidationSpaceβ
Keep the validation space even if there is no validation message
boolean
showCharCounterβ
Should show a character counter (works only with maxLength)
boolean
showClearButtonβ
Should show a clear button when there is a value
boolean
showMandatoryIndicationβ
Whether to show a mandatory field indication
boolean
topTrailingAccessoryβ
Pass to render a top trailing element
ReactElement
trailingAccessoryβ
Pass to render a trailing element
ReactElement
useGestureHandlerInputβ
Use react-native-gesture-handler instead of react-native for the base TextInput
boolean
validateβ
A single or multiple validator. Can be a string (required, email) or custom function.
Validator | Validator[]
validateOnBlurβ
Should validate when losing focus of TextField
boolean
validateOnChangeβ
Should validate when the TextField value changes
boolean
validateOnStartβ
Should validate when the TextField mounts
boolean
validationIconβ
Icon left to the validation message
IconProps
validationMessageβ
The validation message to display when field is invalid (depends on validate)
string | string[]
validationMessagePositionβ
The position of the validation message (top/bottom)
ValidationMessagePosition
validationMessageStyleβ
Custom style for the validation message
TextStyle