shadcn.io is not affiliated with official shadcn/ui
Form examples · Multi Field
Four Field Profile Form for React
A profile form with username, email, bio and website fields, each checked by its own validation rule.
Profile forms collect identity and contact details in one place, and each field needs a different check. This one validates the username's length, the email's format, the bio's length and the website's URL with one Zod schema. The four fields stack in a FieldGroup, each a Field with its FieldLabel, Input and FieldError, and only the username has a FieldDescription. Use it for user profiles, author bios or account settings.
Preview
Installation
FAQ
What does each profile field check?
username is z.string().min(3, …), email is z.email(…), bio is z.string().min(10, …) and website is z.url(…). Their messages: "Username must be at least 3 characters.", "Please enter a valid email address.", "Bio must be at least 10 characters." and "Please enter a valid URL."
Is the bio a textarea?
No, it's a single-line Input with the placeholder Tell us about yourself. For longer bios, swap in a Textarea and keep the same Controller.
What website string passes?
z.url() needs a full URL with a scheme, such as https://example.com, which is also the placeholder. example.com alone fails. The input is type="url".
How are email and username different on the input?
Email sets type="email"; username is a text input with the placeholder johndoe and the description "Your unique username." Each label's htmlFor matches its input's id, such as four-field-profile-form-username.
Related
- Profile Edit FormA profile form prefilled with a username
- Three Field FormA three-field form with first and last
- Form with Optional FieldsA form with required name and email
- URL Input FormA form with one website input that only
- Mixed Input Types FormA registration form that mixes text
- Long Form with Many FieldsA nine-field registration form in three