Text Input Field
Text Input Field Component
The Text Input Field component provides a complete form field for single-line text input with built-in label, validation, error handling, and accessibility support.
Example
Enter your full name as it appears on your ID
Please enter a valid email address
Usage
import TextInputField from "@altitude/ui/react/components/fields/text-input-field";
export default function SignupForm() { return ( <form> <TextInputField id="email" name="email" label="Email Address" helperText="We'll never share your email" placeholder="example@email.com" required={true} />
<TextInputField id="password" name="password" label="Password" type="password" helperText="At least 8 characters" required={true} />
{/* More form fields */} <button type="submit">Sign Up</button> </form> );}Props
| Prop | Type | Required | Description |
|---|---|---|---|
| id | string | No | HTML ID for the field |
| name | string | No | HTML name attribute for the field |
| label | string | No | Label text for the field |
| helperText | string | No | Helper text displayed below the field |
| errorMessage | string | No | Error message displayed when aria-invalid is true |
| placeholder | string | No | Placeholder text for the input |
| required | boolean | No | Whether the field is required (default: false) |
| aria-invalid | boolean | No | Whether the field has an error (default: false) |
| disabled | boolean | No | Whether the field is disabled (default: false) |
| maxlength | number | No | Maximum character count for the field |
| type | string | No | Input type (e.g., “text”, “email”, “password”) |
Additional HTML input attributes can also be passed and will be forwarded to the underlying input element.
Implementation Details
The Text Input Field component combines an input wrapper and a text input component:
- Uses
FieldWrapperto handle labels, error states, and helper text - Uses the base
TextInputUI component for the actual input element - Automatically handles validation states and error messaging