shadcn.io is not affiliated with official shadcn/ui
Input examples · Validation
Multiple Validation Messages Input for React
An invalid password field listing every rule it breaks.
When a value breaks several rules, list them all at once instead of one per attempt. This example marks the password field invalid and shows three messages in FieldError, each with a CircleAlertIcon: too short, no number, no special character. Use it for passwords, usernames and other fields with several rules.
Preview
Installation
FAQ
How are the messages listed?
One FieldError holds the messages, stacked with flex-col gap-1. Each is a row with a CircleAlertIcon and its text, rendered from a static list of strings.
How is the field marked invalid?
invalid on Field, which sets aria-invalid on the input and gives it a destructive border and ring.
Are the rules checked as I type?
No. The value pass and the messages are fixed, to show the invalid state. Compute the list from the value to make it live, as the Real-time Validation example does.
Related
- Error State InputAn invalid email field with an error
- Real-time Validation InputA password field with a checklist of
- Password with Toggle InputA password field with a button that shows
- Warning State InputA password field in a warning state, with
- Simple Text Input FormA form with one username text input that
- Input with LabelA text input with a label above it