Overview
TextInput is the reusable text field used across RLink forms. It wraps the base Input component and adds:
- optional label rendering
- required indicator
- built-in validation hints
- password visibility toggle
- shared styling through
cn()
Source
The component is implemented incomponents/ui/TextInput.tsx.
Props
| Prop | Type | Required | Notes | ||||
|---|---|---|---|---|---|---|---|
name | string | Yes | Used for field identity and auto-validation detection | ||||
type | string | Yes | Common values: text, email, password, tel, number | ||||
placeholder | string | Yes | Placeholder text shown in the input | ||||
value | string | Yes | Controlled value | ||||
onChange | (e: React.ChangeEvent) => void | Yes | Controlled change handler | ||||
label | string | No | Field label rendered above the input | ||||
className | string | No | Extra styling classes | ||||
required | boolean | No | Shows * beside the label | ||||
disabled | boolean | No | Disables editing | ||||
validationType | `“email" | "name" | "phone" | "Employee ID" | "none”` | No | Overrides auto-detected validation |
Auto-validation behavior
TextInput automatically chooses a validation type from name and type when validationType is not passed.
Current detection rules:
type="email"or names containingemail-> email validation- names like
firstname,lastname,name,first,last-> name validation type="number",type="tel", or names containingphone-> phone validationtype="text"withnamecontainingemployeeId-> employee ID validation- otherwise -> no validation
Validation only appears once the field has a value. Empty values are treated as valid here, so required-state enforcement should still happen at the form level.
Password behavior
Whentype="password", the component adds a visibility toggle using the eye icon button. This makes it a good default for login, reset-password, or security forms.
Basic usage
Password example
Custom validation override
UsevalidationType when the field name is too generic to infer safely.
Best practices
- Keep
TextInputcontrolled with local or form state - Use meaningful
namevalues so auto-validation works - Override
validationTypewhen inference would be ambiguous - Keep required validation in the form schema or submit handler too
- Use consistent labels and placeholders across the app
Edge cases
Empty values
The component does not mark an empty field invalid. That is intentional so optional fields do not show errors immediately.Generic field names
A field namedvalue or input will not infer useful validation. Pass validationType explicitly if you want validation messaging.
Phone numbers
type="number" and type="tel" both map to phone validation. If you use those input types for non-phone numeric fields, set validationType="none".
Password managers
The show/hide toggle changes the rendered input type betweenpassword and text. Test autofill behavior on login and reset screens after changing markup around this component.
Related docs
DropSelect
Documented select wrapper for consistent field styling
FileUpload
Image upload field backed by
/api/uploadStyling guide
Shared UI patterns and class conventions
Dashboard overview
Where these components appear in the app
