Password Input
Secure password input with show/hide toggle functionality.
Featuresβ
- π Secure text entry
- ποΈ Show/hide toggle
- β¨οΈ Optimized keyboard
- π Auto-complete support
Basic Usageβ
import {Input} from '@tansuk/rott-ui'
<Input
name='password'
type='password'
placeholder='Enter password'
value={password}
onChangeText={setPassword}
/>
With Labelβ
<Input
name='password'
type='password'
label='Password'
placeholder='Min 8 characters'
value={password}
onChangeText={setPassword}
/>
With Validationβ
<Input
name='password'
type='password'
label='Password'
value={password}
onChangeText={setPassword}
errorMessage={errors.password}
touched={touched.password}
/>
Propsβ
| Prop | Type | Description |
|---|---|---|
name | string | Required - Input identifier |
type | 'password' | Required - Must be 'password' |
value | string | Current value |
onChangeText | (text: string) => void | Change handler |
placeholder | string | Placeholder text |
label | string | InputLabelProps | Input label |
errorMessage | string | Error message |
touched | boolean | Validation touched state |
Featuresβ
Show/Hide Toggleβ
Automatically includes an eye icon to toggle password visibility.
Securityβ
- Secure text entry by default
- No copy/paste on some platforms
- Auto-complete: 'password'
Validation Exampleβ
import {Formik} from 'formik'
import * as Yup from 'yup'
const PasswordSchema = Yup.object().shape({
password: Yup.string()
.min(8, 'Too short')
.matches(/[A-Z]/, 'Need uppercase')
.matches(/[0-9]/, 'Need number')
.required('Required'),
})
<Formik
initialValues={{password: ''}}
validationSchema={PasswordSchema}
onSubmit={handleSubmit}>
{({handleChange, values, errors, touched}) => (
<Input
name='password'
type='password'
label='Password'
placeholder='Min 8 characters'
value={values.password}
onChangeText={handleChange('password')}
errorMessage={touched.password ? errors.password : ''}
touched={touched.password}
/>
)}
</Formik>
Confirm Passwordβ
<Input
name='password'
type='password'
label='Password'
value={password}
onChangeText={setPassword}
/>
<Input
name='confirmPassword'
type='password'
label='Confirm Password'
value={confirmPassword}
onChangeText={setConfirmPassword}
errorMessage={password !== confirmPassword ? 'Passwords must match' : ''}
/>
Relatedβ
- Input - Main input documentation
- Email Input - Email input
- PIN Input - PIN/OTP input