Skip to main content

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​

PropTypeDescription
namestringRequired - Input identifier
type'password'Required - Must be 'password'
valuestringCurrent value
onChangeText(text: string) => voidChange handler
placeholderstringPlaceholder text
labelstring | InputLabelPropsInput label
errorMessagestringError message
touchedbooleanValidation 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' : ''}
/>