shadcn.io is not affiliated with official shadcn/ui
Form examples · Layouts
Responsive Layout Form for React
A form that stacks name, email, company and website in one column on small screens and shows two columns from the md breakpoint up.
Vertical on phones for clarity, two columns on wider screens to save height. The four Fields sit in a grid grid-cols-1 gap-4 md:grid-cols-2 inside the FieldGroup: below md they stack, from md up name sits beside email and company beside website. Each Field has its FieldLabel, Input, an optional FieldDescription and its FieldError, wired to React Hook Form with a Controller and checked by one Zod schema.
Preview
Installation
FAQ
How does the grid change width?
One div with grid grid-cols-1 gap-4 md:grid-cols-2 holds the four fields. Below the md breakpoint they stack. From md up they fill two rows of two. The form is max-w-2xl.
What does the schema require?
name and company are z.string().min(2), email is z.email() and website is z.url(). None passes a custom message, so FieldError shows Zod's defaults, such as Invalid URL.
Which fields have a description?
Name has the FieldDescription Your full name. and email has Your work email. Company and website have a label, an input and a FieldError only.
Related
- Grid Layout (2 Columns) FormA contact details form with six fields in
- Responsive Layout FieldTwo fields that stack in a narrow
- Vertical Layout (Default) FormA form with labels above their inputs and
- Horizontal Layout FormA form with each label beside its input
- Spacious Form with SectionsA spacious form split into Personal
- Accordion Form with Icon SectionsA form split into personal, contact and