Directory
- Welcome
TextArea Component
The TextArea component provides a robust solution for multi-line text input in forms. Built with accessibility and flexibility in mind, it offers customizable styling, validation states, and seamless integration with your design system.
Key Features
-
Accessible Design: Built-in labels and ARIA support
-
Multiple Variants: Default and underline styles
-
Validation States: Support for required fields and error states
-
Auto-resizing: Height adjusts to content while remaining user-resizable
Variants
Default Variant
The standard style with a bordered container:
<TextArea variant="default" label="Message" placeholder="Enter your message here"/>
Underline Variant
A minimal style with bottom border only:
<TextArea variant="underline" label="Minimal Input" placeholder="Clean, understated design"/>
TextArea Component Props API
Prop | Type | Default | Description |
---|---|---|---|
label | string | Label text shown above the textarea | |
subLabel | string | Helper text shown below the textarea | |
variant | default | underline | default | Visual style of the textarea |
States and Examples
Required Fields
<TextArea label="Required Message" required placeholder="This field cannot be empty"/>
With Sub-Label
<TextArea label="Your Bio" subLabel="Maximum 500 characters" placeholder="Tell us about yourself"/>
Disabled State
<TextArea label="Disabled Input" disabled placeholder="This field cannot be edited"/>
Best Practices
-
Labels and Instructions
- Always provide clear, descriptive labels
- Use sub-labels for additional context
- Keep placeholder text minimal
-
Validation and Feedback
- Clearly indicate required fields
- Provide immediate validation feedback
- Use appropriate error messages
Limited Time Launch Sale
Start building accessible, beautiful forms today with our AstroJS starter template. Get instant access to the TextArea component and many more pre-built UI elements.
GET 60% OFF!