shadcn.io is not affiliated with official shadcn/ui
Input examples · Special
Disabled Input for React
A disabled field showing an account ID that can't be edited.
Some values are shown but not editable. This example disables the Account ID field, prefilled with ACC-12345, and a description under it says it can't be edited, so the locked state reads as intended rather than broken. Use it for system-generated IDs, computed values and settings someone else manages.
Preview
Installation
FAQ
What does disabling the field do?
The input can't be focused or edited, it's skipped by Tab, and it's left out of the form's submitted data. It's dimmed with disabled:opacity-50 and shows a not-allowed cursor.
Where is disabled set?
On the Input, the native disabled attribute. The label stays at full strength.
How is the account ID shown?
As the input's default value, ACC-12345. The field is disabled, so it never changes and needs no change handler.
When should I use readOnly instead?
When people should still focus, select and copy the value, or when the form must submit it. A read-only field stays in the tab order and in the submitted data; a disabled one does neither.
Related
- Input with LabelA text input with a label above it
- File Upload with List InputA multiple file input that lists the
- Profile Edit FormA profile form prefilled with a username
- Badge with Text (Standard)A default badge with a short label for a
- Standard CardA basic card with a title, a description
- Simple TooltipAn outline button that shows a one-line