Input
The Input component supports 14+ different input types including text, email, password, date, phone, IBAN, credit card, and more.
Featuresβ
- π 14+ input types
- β Validation support
- π Input masking
- π Date/DateTime pickers
- π Search with autocomplete
- π° Amount input
- βοΈ Checkbox variant
- π¨ Light/dark themes
- πΌοΈ Leading/trailing icon slots (
leftIcon/rightIcon)
Basic Usageβ
import {Input} from '@tansuk/rott-ui'
<Input
name='email'
type='email'
placeholder='Enter your email'
value={email}
onChangeText={setEmail}
/>
Input Typesβ
Each input type has its own dedicated page with specific props, examples, and best practices:
- Amount - Currency and numeric input with formatting
- Checkbox - Checkbox input
- Credit Card - Credit card number with masking
- CVC - Card security code
- Date - Date and datetime picker
- Email - Email input with validation
- Expire Date - Card expiration date
- IBAN - IBAN with formatting
- Numeric - Numbers only
- Password - Password with show/hide
- Phone - Phone number with masking
- PIN - PIN/OTP input
- Search - Search with autocomplete
- Select - Dropdown select
With Labelsβ
<Input
name="email"
type="email"
label="Email Address"
placeholder="Enter your email"
/>
Validationβ
<Input
name="email"
type="email"
placeholder="Email"
value={email}
onChangeText={setEmail}
errorMessage={errors.email}
touched={touched.email}
/>
Propsβ
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | Required | Input identifier |
type | InputType | 'default' | Input type |
value | string | - | Input value |
onChangeText | (text: string) => void | - | Change handler |
placeholder | string | - | Placeholder text |
label | string | InputLabelProps | - | Input label |
errorMessage | string | - | Error message |
touched | boolean | false | Touched state |
theme | 'light' | 'dark' | 'light' | Theme |
disabled | boolean | false | Disabled state |
leftIcon | InputIconProps | - | Leading icon slot (rendered only when provided) |
rightIcon | InputIconProps | - | Trailing icon slot (rendered only when provided) |
InputIconPropsβ
leftIcon and rightIcon extend IconProps (so name, variant, color,
width, height, mode, β¦ all apply) plus an optional onPress handler:
| Prop | Type | Default | Description |
|---|---|---|---|
name | IconKeys | Required | Icon to render |
variant | Variant | - | Tint via theme variant |
color | string | - | Tint via raw color (takes precedence over variant) |
onPress | (event) => void | - | Makes the icon pressable |
Quick Exampleβ
import {Input} from '@tansuk/rott-ui'
// Basic text input
<Input name='username' type='default' placeholder='Username' />
// Email with validation
<Input name='email' type='email' label='Email' />
// Password with show/hide
<Input name='password' type='password' label='Password' />
// Phone with masking
<Input name='phone' type='phone' mask='+1 ([000]) [000]-[0000]' />
Bordered inputsβ
Passing a border draws a boxed border and automatically hides the bottom
underline Separator (a box and an underline are mutually exclusive). To keep
the underline as well, pass renderSeparator explicitly:
<Input name='boxed' border={{width: 1, radius: 8, variant: 'grey-200'}} />
<Input name='boxed-with-line' border={{width: 1}} renderSeparator />
Leading & trailing iconsβ
Every input type accepts leftIcon and rightIcon. A slot is rendered only
when the corresponding prop is provided, and the field flexes to fill the
space between the icons β so the text area automatically grows or shrinks based
on which icons are present:
// Leading icon only β text fills the remaining width
<Input name='email' type='email' leftIcon={{name: 'mail'}} />
// Both slots β text sits between the two icons
<Input
name='search'
leftIcon={{name: 'search'}}
rightIcon={{name: 'close', onPress: clear}}
/>
// No icons β text spans the full width
<Input name='plain' />
The gap between an icon and the text is spacing-aware (a multiple of 4, scaled
by size).
Tintingβ
Icons accept variant and color to tint them via props (no need to bake the
color into the SVG). color takes precedence over variant:
<Input name='email' leftIcon={{name: 'mail', variant: 'primary'}} />
<Input name='locked' leftIcon={{name: 'lock', color: '#FF6B6B'}} />
Pressable iconsβ
Pass onPress to make a slot interactive (rendered as an accessible button):
<Input name='amount' rightIcon={{name: 'info', onPress: showHelp}} />
Built-in trailing iconsβ
Functional types keep their built-in trailing behavior while letting you
override the appearance via rightIcon. The function stays locked:
passwordβ show/hide eye (toggle is always the eye's job)phoneβ contacts pickeribanβ clear / QRamountβ currency indicatordateβ calendar (opens the picker)select/multiSelectβ chevron (or the read-onlyid-card)
// Swap the eye's look, keep the show/hide function
<Input name='password' type='password' rightIcon={{name: 'eye-alt'}} />
Control typesβ
checkbox and toggle place leftIcon/rightIcon around their content (box or
switch). Their icon slots use press isolation, so tapping a pressable icon does
not toggle the control.
iconThe former icon prop has been removed. Replace icon={{β¦}} with
leftIcon={{β¦}} (same shape). Margin/padding you pass to Input is applied to
the field's outer container β it no longer leaks into the inner TextInput.
Relatedβ
- Forms Guide - Complete form examples with validation
- Toggle - Toggle switch component