shadcn.io is not affiliated with official shadcn/ui
Form examples · Patterns
Signup Form for React
A sign-up form with full name, email, a password that needs mixed case and a number, and a required terms checkbox.
Registration needs a few fields done right. This sign-up form asks for a full name, an email and a password that must be 8 characters with an uppercase letter, a lowercase letter and a number, then a terms checkbox that must be checked. Each field is a Field with its FieldLabel and FieldError, wired to React Hook Form by a Controller, and a sign in link sits under the full-width button. Use it for account creation and onboarding.
Preview
Installation
FAQ
What does the password schema require?
.min(8) with "Password must be at least 8 characters.", then three .regex checks at module scope: an uppercase letter, a lowercase letter and a number, each with its own message. The FieldError shows the first that fails.
Where are those rules written before an error?
In the password's FieldDescription, set to text-xs: "Must contain uppercase, lowercase, and number". It shows before any submit.
How is the terms box required?
terms is z.boolean().refine((value) => value, …) with "You must accept the terms and conditions.", and it starts false. The Checkbox takes checked and onCheckedChange={field.onChange}.
What is inside the terms label?
The FieldLabel reads I agree to the terms and conditions, with terms and conditions as an a to href="#". It sits in a FieldContent beside the checkbox, with the FieldError under it.
Related
- Login FormA login form with a welcome heading
- Password Strength Validation FormA password that needs 8 characters with
- Profile Edit FormA profile form prefilled with a username
- Form with CheckboxA form with three checkboxes and their
- Simple CheckboxA checkbox with a label for a single
- Vertical Layout (Default) FormA form with labels above their inputs and