Skip to content
React NativeBeta

Input & OtpInput

Text fields with label, hint and error, clear and reveal buttons, a character count, and a one-time-code input that fills from SMS.

Beta. React Native support is in beta. APIs may change or break between prereleases (npm tag native).

On this page
Web preview — real device may differ
tsx
import { useState } from "react";
import { Text } from "react-native";
import { Input, OtpInput } from "@/component-lib/input";
import { useKitTheme } from "@/component-lib/shared/native";
import { Section } from "./layout"; // Section and Row: page layout for the demo
 
export function InputDemo() {
  const { tokens } = useKitTheme();
  const [code, setCode] = useState("");
  const [done, setDone] = useState<string | null>(null);
  return (
    <>
      <Section title="Input · basics">
        <Input label="Full name" placeholder="Anand Remanan" clearable defaultValue="Anand" />
        <Input
          label="Email"
          type="email"
          placeholder="you@example.com"
          description="We never share it."
          required
        />
        <Input label="Password" type="password" defaultValue="hunter22" />
        <Input
          label="Website"
          type="url"
          leading="https://"
          placeholder="gramproindia.com"
        />
        <Input label="Weight" type="number" trailing="kg" defaultValue="72.5" />
      </Section>
 
      <Section title="Input · states">
        <Input label="Bio" showCount maxLength={20} defaultValue="Builds 👨‍👩‍👧 UI kits" />
        <Input label="PAN" defaultValue="ABCDE1234" error="PAN has 10 characters." />
        <Input label="Read only" readOnly defaultValue="INV-2026-0042" />
        <Input label="Disabled" disabled defaultValue="Can't touch this" />
        <Input size="sm" placeholder="Small" />
        <Input size="lg" placeholder="Large" />
      </Section>
 
      <Section title="OtpInput">
        <OtpInput
          label="Verification code"
          description="Sent to +91 98xxx xx210. Paste the whole SMS to fill it."
          value={code}
          onValueChange={setCode}
          onComplete={setDone}
        />
        {done ? <Text style={{ color: tokens.success }}>Completed: {done}</Text> : null}
        <OtpInput label="Grouped, masked" length={6} groups={[3, 3]} mask defaultValue="123" />
        <OtpInput label="Alphanumeric" length={4} mode="alphanumeric" uppercase error="Code expired." />
      </Section>
    </>
  );
}

Install

npx @grampro/kit@native add Input

Usage

tsx
import { Input, OtpInput } from "@/component-lib/input";
 
<Input label="Email" type="email" required description="We never share it." />
<OtpInput label="Verification code" length={6} onComplete={verify} />

Props

InputProps

PropTypeDescription
valuestring
defaultValuestring
onValueChange(value: string) => voidThe new text on every change. onChangeText fires as well.
typeInputTypePicks the keyboard, autofill and secure entry, as type does on the web. Default text.
labelReactNodeThe field's name, shown above it.
descriptionReactNodeA hint under the field, read as the field's hint.
errorReactNodeMessage below the field; also marks it invalid.
sizeFieldSizeDefault md.
leadingReactNodeContent before the text, e.g. an icon or "https://".
trailingReactNodeContent after the text, e.g. a unit such as "kg".
clearablebooleanA button that empties the field. Default false.
revealPasswordbooleanFor type="password", a button that shows the text. Default true.
showCountbooleanA character counter under the field; shows count / maxLength when maxLength is set.
disabledboolean
readOnlyboolean
requiredbooleanMarks the label with an asterisk. Native has no form validation of its own.
styleStyleable<ViewStyle>
stylesPartial<{ root: Styleable<ViewStyle>; label: Styleable<TextStyle>; control: Styleable<V…
localeTextPartial<InputLocaleText>

Also accepts the props of Omit<TextInputProps, "value" | "defaultValue" | "style" | "editable" | "secureTextEntry">.

OtpInputProps

PropTypeDescription
lengthnumberNumber of characters. Default 6.
modeOtpModeDefault numeric.
uppercasebooleanTurn letters into capitals as they are typed.
valuestring
defaultValuestring
onValueChange(value: string) => void
onComplete(value: string) => voidEvery cell is filled.
groupsnumber[]Group sizes with a separator between them, e.g. [3, 3].
maskbooleanShow dots instead of the characters.
labelReactNode
descriptionReactNode
errorReactNode
sizeFieldSize
disabledboolean
readOnlyboolean
requiredboolean
styleStyleable<ViewStyle>
stylesPartial<{ root: Styleable<ViewStyle>; label: Styleable<TextStyle>; cells: Styleable<Vie…
localeTextPartial<InputLocaleText>

Also accepts the props of Omit< TextInputProps, "value" | "defaultValue" | "style" | "editable" | "maxLength" | "keyboardType" | "inputMode" | "secureTextEntry" >.

Native and web

  • type picks the keyboard, autofill and secure entry. onChangeText fires alongside onValueChange.
  • OtpInput is one real TextInput under drawn cells, so paste and SMS autofill (oneTimeCode, sms-otp) fill every cell.
  • description and error become the accessibility hint; errors are announced.
  • Web version: Input & OtpInput on the web.