Skip to main content

Inputs

All text inputs extend TextInputProps, so value, onChangeText, editable, keyboardType, ... work as usual.

Input​

Single line field with optional label, icons and error message.

npx midestic-rn-library add input
<Input label="Email" placeholder="you@example.com" value={email} onChangeText={setEmail} />
<Input label="Email" error="Enter a valid email address" value={bad} onChangeText={setBad} />
<Input placeholder="Search" leftIcon={<SearchIcon />} />
PropTypeDefaultDescription
labelstring-Text rendered above the field
errorstring-Turns the border red and shows the message
leftIcon / rightIconReactNode-Icons inside the field
onLeftIconPress / onRightIconPress() => void-Make the icons pressable
classNamestring""Extra classes on the wrapper

NumberInput​

Numeric field with variant/size styling.

npx midestic-rn-library add number-input
<NumberInput label="Age" placeholder="18" keyboardType="number-pad" />
<NumberInput label="Amount" error="Minimum is 500" size="sm" />
PropTypeDefaultDescription
labelstring-Label above the field
errorstring-Error message + border-warning
variantdefault | error | disabledderivedExplicit visual state
sizesm | md | lgmdLabel/input font size
fullWidthboolean-Stretch to container
inputClassNamestring""Extra classes on the TextInput itself

Textarea​

Multi line field.

npx midestic-rn-library add textarea
<Textarea placeholder="Tell us something..." numberOfLines={4} containerClassName="h-[140px]" />
PropTypeDescription
classNamestringExtra classes on the TextInput
containerClassNamestringExtra classes on the wrapper

SearchInput​

Search field with leading/trailing icons (a magnifier by default).

npx midestic-rn-library add search-input
<SearchInput placeholder="Search trips" />

PhoneInput​

Phone field with a country flag and code prefix.

npx midestic-rn-library add phone-input
<PhoneInput label="Phone number" countryCode="+234" placeholder="8012345678" />
<PhoneInput flag={<CustomFlag />} ... />
PropTypeDescription
flagImageSourcePropType | ReactNodeReplaces the default flag
countryCodestringText shown before the field
labelstringLabel above the field

SelectInput​

Controlled dropdown.

npx midestic-rn-library add select-input
const [city, setCity] = useState<string | undefined>();

<SelectInput
label="City"
value={city}
onValueChange={setCity}
placeholder="Pick a city"
options={[
{ label: "Lagos", value: "lagos" },
{ label: "Abuja", value: "abuja" },
]}
/>;
PropTypeDescription
optionsSelectOption[] ({ label, value })Items shown in the sheet
value / onValueChangestring / (value: string) => voidControlled value
label / placeholderstringLabel and placeholder

OTPInput / OTPInputSquare​

Digit boxes for one time codes. Both are controlled by value/onChangeText, and every box exposes accessibilityLabel={"Digit " + index}.

Add either component individually:

npx midestic-rn-library add otp-input
npx midestic-rn-library add otp-input-square
const [code, setCode] = useState("");

<OTPInput length={6} value={code} onChangeText={setCode} />
<OTPInputSquare length={4} value={code} onChangeText={setCode} />
PropTypeDefaultDescription
lengthnumber4Number of boxes
valuestring-Controlled value
onChangeText(value: string) => void-Fires with the whole code
classNamestring-Extra classes on the row