shadcn.io is not affiliated with official shadcn/ui
Textarea examples · Standard
Disabled Textarea for React
A disabled textarea that is dimmed and can't be focused or edited.
A disabled Textarea shows a field that isn't available right now: one that unlocks after another choice, waits on a permission, or is locked while a save runs. Setting disabled dims it to half opacity and shows a not-allowed cursor, and the browser takes it out of the tab order and out of the form's submitted values.
Preview
Installation
FAQ
What's the difference between disabled and readOnly?
A disabled Textarea is dimmed, can't be focused, is skipped by Tab, and its value is left out when the form submits. A readOnly one looks like any other field, can be focused, lets people select and copy its text, and submits its value. Use disabled when the field doesn't apply yet, and readOnly when the value should be seen and sent but not changed, as in the Read-only Textarea example.
Can I customize the styling of disabled textareas?
Yes. The Textarea already has disabled:opacity-50 and disabled:cursor-not-allowed, and classes you pass with the disabled: variant add to them, for example disabled:bg-muted. Keep the state clearly different from an editable field, since the styling is the only cue sighted users get.
How do I conditionally enable or disable a textarea?
Bind disabled to a boolean from your component's state, such as a saving flag or a permission check, instead of hard-coding it. The Textarea turns editable again as soon as the value is false.
Should I show a tooltip explaining why the textarea is disabled?
Explain it, but in visible text such as a FieldDescription under the field. A tooltip on the Textarea itself never opens for keyboard users, because a disabled field can't receive focus, and touch users have no hover to open it.
Related
- Read-only TextareaA read-only textarea whose text can be
- Simple TextareaA plain textarea with a placeholder and
- Textarea with LabelA textarea with a visible label above it
- Disabled InputA disabled field showing an account ID
- Short TextareaA compact textarea fixed at three rows
- Required TextareaA required textarea with a red asterisk