Input

Forms

Feature-rich text input with 3 sizes, prefix/suffix slots, floating label, password toggle, clearable, character count, shake on error, and haptic on focus.

GitHub

Installation

bash
1
npx native-mate add input

Examples

#FAFAFA
Radius100%

Usage

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Input } from '~/components/ui/input'

// Basic
<Input label="Email" placeholder="you@example.com" />

// Sizes
<Input size="sm" placeholder="Small" />
<Input size="lg" placeholder="Large" />

// Required
<Input label="Name" required />

// Prefix & suffix text
<Input label="Price" prefixText="$" suffixText="USD" />
<Input label="Website" prefixText="https://" />

// Prefix & suffix icons
<Input prefix={<SearchIcon />} placeholder="Search..." clearable />
<Input suffix={<CheckIcon />} label="Email" />

// Password with toggle
<Input label="Password" secureTextEntry showPasswordToggle />

// Character count
<Input label="Bio" showCount maxLength={160} />

// Floating label (Material Design style)
<Input floatingLabel label="Email Address" />

// Error (triggers shake animation)
<Input label="Username" error="Already taken" />

// Haptic on focus
<Input label="Name" hapticOnFocus />

Props

PropTypeDefaultDescription
labelstringLabel shown above the input (or floating inside when floatingLabel is true).
errorstringError message shown below. Turns border red and triggers shake animation.
hintstringHelper text shown below the input.
size"sm" | "md" | "lg""md"Controls height, font size, and padding.
requiredbooleanfalseShows a red asterisk (*) after the label.
disabledbooleanfalseDims input and prevents editing.
prefixReact.ReactNodeIcon or element rendered inside the input, before the text.
suffixReact.ReactNodeIcon or element rendered inside the input, after the text.
prefixTextstringText addon attached to the left (e.g. "$", "https://"). Has a border separator.
suffixTextstringText addon attached to the right (e.g. "USD", ".com"). Has a border separator.
clearablebooleanfalseShows a clear (×) button when input has a value.
onClear() => voidCalled when the clear button is pressed.
showPasswordTogglebooleanfalseShows a Show/Hide toggle for password inputs. Use with secureTextEntry.
showCountbooleanfalseShows character count below the input. Pair with maxLength.
maxLengthnumberMaximum character limit. Shown as x/max when showCount is true.
floatingLabelbooleanfalseLabel animates from placeholder position to top of border on focus (Material Design style).
hapticOnFocusbooleanfalseTriggers a light haptic tap when input is focused. Requires expo-haptics (optional).
...TextInputPropsTextInputPropsAll standard React Native TextInput props are forwarded.

Example

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Input } from '~/components/ui/input'
import { View } from 'react-native'

export function InputExamples() {
  return (
    <View style={{ gap: 16, padding: 16 }}>
      <Input label="Email" placeholder="you@example.com" />
      <Input label="Price" prefixText="$" suffixText="USD" />
      <Input label="Password" secureTextEntry showPasswordToggle />
      <Input label="Bio" showCount maxLength={160} />
      <Input floatingLabel label="Floating Label" />
      <Input label="Search" placeholder="Type..." clearable />
      <Input label="Username" error="Already taken" />
      <Input label="Company" disabled value="Acme Inc." />
    </View>
  )
}

Accessibility

FeatureDetail
LabelaccessibilityLabel is auto-set from the label prop.
Disabled stateaccessibilityState={{ disabled }} is set when disabled.
KeyboardFully focusable and editable via assistive technology.