Textarea

Accessibility

NameTypeDescription
ariaLabelstringAllows you to specify an aria-label attribute of the component.
ariaLabelledbystringAllows you to specify an aria-labelledby attribute of the component.
  1. Always prefer visible labels - Use the label prop whenever possible as visible labels benefit all users.
  2. Use ariaLabel only when a visible label cannot be provided.
  3. Use ariaLabelledby to associate the textarea with an existing visible label elsewhere in the DOM.
  1. Assign a unique id to the element that serves as the label
  2. Pass that id value to the ariaLabelledby prop of the Textarea component
  3. For multiple labels, provide space-separated ids (e.g., "id1 id2 id3")

Examples

// PREFERRED: Using the built-in label prop
<Textarea label="Feedback" placeholder="Please share your thoughts with us" />
// Use ariaLabel ONLY when a visible label cannot be provided
<Textarea
placeholder="Please share your thoughts with us"
ariaLabel="Feedback form for customer comments"
/>
// Use ariaLabelledby to reference an existing visible label elsewhere in the DOM
<div>
<h3 id="feedback-heading">Share Your Feedback</h3>
<p>We value your opinion about our services.</p>
<Textarea placeholder="Please share your thoughts with us" ariaLabelledby="feedback-heading" />
</div>
// Multiple label references
<span id="form-context">Flight #KI2807</span>
<h3 id="feedback-section">Passenger Feedback</h3>
<Textarea ariaLabelledby="form-context feedback-section" placeholder="Tell us about your experience" />
// Using both ariaLabelledby and ariaLabel (ariaLabelledby takes precedence)
<div>
<h3 id="feedback-title">Customer Feedback</h3>
<Textarea
ariaLabelledby="feedback-title"
ariaLabel="Share your thoughts about our service"
placeholder="Tell us what you think"
/>
</div>

Help and Error Messages

<Textarea
label="Feedback"
placeholder="Please share your thoughts with us"
error="This field is required"
/>

Detached Label

<label htmlFor="feedback-textarea">Your feedback</label>
<Textarea
id="feedback-textarea"
placeholder="Please share your thoughts with us"
/>

Best Practices