React Native · Components
TextField
Labeled text field: label, description, error message, required marker, password show/hide and icons.
Import
TextField
componentLabeled text field: label, description, error message, required marker, password show/hide and icons. On focus a 2 px border in the theme color (inset like on web; text does not shift), the danger color on error.
Examples
applyMask
functionFormats text with a mask. Also useful outside components: showing a stored unmasked value in a list, validating on the server, etc. Also runs on the server.
Examples
MaskToken
interfaceWhich characters a letter in a mask pattern accepts.
| Name | Type | Description |
|---|---|---|
test | RegExp | Regular expression that tests a single character. When transform is set, the transformed character is tested. |
transform? | (char: string) => string | Transforms the character before accepting it (e.g. to uppercase). |
Examples
MaskPreset
typeBuilt-in masks. Each brings the pattern, the mobile keyboard type (inputMode), the autofill hint and, where needed, checksum validation.
phone: Turkish phone number,0 (532) 123 45 67. Same result whether or not the leading 0 is typed.phoneIntl: Turkish phone number in international format,+90 (532) 123 45 67.plate: Turkish license plate,34 ABC 123. Letters are uppercased; the province code (01–81) and the letter/digit count rule are checked.tckn: Turkish national ID number, 11 digits; validated with the official algorithm.taxNumber: Turkish tax ID number (VKN), 10 digits.iban: Turkish IBAN,TR12 3456 …; validated with the mod-97 checksum.card: Credit card,1234 5678 9012 3456; validated with Luhn.expiry: Card expiry date,MM/YY.date: Date,DD.MM.YYYY; checked to be a real day.time: Time,HH:MM(00:00–23:59).postalCode: Postal code, 5 digits.
MaskOptions
interfaceDetailed mask definition. See MaskProp.
| Name | Type | Description |
|---|---|---|
pattern | string | readonly string[] | Pattern or patterns. With an array, the pattern that best fits the input is used (e.g. different formats for landlines and mobiles). See MaskProp. |
tokens? | Record<string, MaskToken> | Additional or overridden letters to use in the pattern. |
validate? | (unmasked: string, formatted: string) => boolean | Called when the value is complete; returning false marks the field invalid (customError) and shows invalidMessage. Receives the value without separators (see MaskResult.unmasked). |
invalidMessage? | string | Message shown when validate fails. Defaults to the maskInvalid text in the dictionary. |
placeholder? | string | Placeholder shown while the field is empty. Generated from the pattern by default ((___) ___). |
inputMode? | "text" | "numeric" | "tel" | "decimal" | Mobile keyboard. Defaults to numeric when the pattern only asks for digits. |
autoComplete? | string | Browser autofill hint (e.g. tel-national). |
MaskProp
typeMask of a field. Given in three forms:
- Built-in mask name (
MaskPreset):"phone","plate","iban"… - Pattern (or an array of patterns): the letters below stand for a character the user types; everything else is a literal that is inserted automatically.
9: digita: letter (including Turkish letters)A: letter, converted to uppercase*: letter or digitX: letter or digit, converted to uppercase{n}/{n,m}/{n,}: how many times the previous letter repeats (e.g.A{1,3}is 1–3 letters). In a variable-length section, type the separator (e.g. a space) to move to the next section, or just type a character of the next kind.\: makes the next character a literal (\9→ "9").- Detailed definition (
MaskOptions): custom letters, validation, placeholder, keyboard type.
Examples
MaskResult
interfaceResult of applyMask.
| Name | Type | Description |
|---|---|---|
value | string | Formatted text (shown in the field). |
unmasked | string | Value without separators: the typed characters and letter/digit literals of the pattern (0 (532) 123 45 67 → "05321234567", 34 ABC 123 → "34ABC123"). |
complete | boolean | Are all required sections of the pattern filled? false for an empty value. |
valid | boolean | Does the complete value pass the mask's validation? Same as complete for masks without validation. |
PasswordReveal
typePassword reveal mode (same as web).
"hold": visible while the eye button is held."toggle": each tap toggles it.false: no button.
TextFieldProps
interfaceTextField props.
Extends: FieldProps, Omit<TextInputProps, "editable" | "style">
| Name | Type | Default | Description |
|---|---|---|---|
ref? | Ref<TextInputRef> | Ref of the underlying native element. | |
variant? | FieldVariant | "outline" | Appearance. See FieldVariant. |
type? | "text" | "password" | "text" | "password" is a password field (hidden text + eye button). |
reveal? | PasswordReveal | "hold" | Password reveal. See PasswordReveal. |
icon? | IconProp | Icon at the start of the box. | |
iconEnd? | IconProp | Icon at the end of the box. | |
readOnly? | boolean | Read-only: can be focused, selected and copied but not changed. | |
mask? | MaskProp | Input mask: formats input by a pattern (phone, plate, IBAN…). Same engine and same built-in names as mask on web; keyboard type, placeholder and capitalization are set automatically. For a complete value whose checksum fails (e.g. a wrong IBAN) an error shows on blur. See MaskProp. | |
onValueChange? | (value: string, details: MaskResult) => void | Only with mask: called with the formatted text and details (unmasked, complete, valid) when the value changes. See MaskResult. | |
style? | StyleProp<ViewStyle> | Style of the box. |