shadcn.io is an independent project built on shadcn/ui
First and last name share a row and need 2 characters. Email must be an address. Company can be blank. Website can be blank too, but a filled website must be a valid URL.
Use it when some answers are nice to have and the rest are not. Marking nothing optional forces every Input. In React, Ark UI does not treat a field as optional.
Installation
Usage
<form className="w-full max-w-md" onSubmit={form.handleSubmit(onSubmit)}>
<FieldGroup>
<div className="grid grid-cols-2 gap-4">
<Controller
control={form.control}
name="firstName"
render={({ field, fieldState }) => (
<Field invalid={fieldState.invalid}>
<FieldLabel>First Name</FieldLabel>
<Input {...field} placeholder="John" />
<FieldError>{fieldState.error?.message}</FieldError>
</Field>
)}
/>
<Controller
control={form.control}
name="lastName"
render={({ field, fieldState }) => (
<Field invalid={fieldState.invalid}>
<FieldLabel>Last Name</FieldLabel>
<Input {...field} placeholder="Doe" />
<FieldError>{fieldState.error?.message}</FieldError>
</Field>
)}
/>
</div>
<Controller
control={form.control}
name="email"
render={({ field, fieldState }) => (
<Field invalid={fieldState.invalid}>
{/* The rest of the file is under Installation. */}FAQ
Which fields are required?
firstName and lastName need at least 2 characters, with "First name must be at least 2 characters." and "Last name must be at least 2 characters." email is z.email(…) with "Please enter a valid email address."
Why can company be left blank?
company is z.string().optional() with no length rule, so an empty string passes. Its label reads Company (Optional) and its description asks "Where do you work?"
What website values pass?
website is z.url().optional().or(z.literal("")): an empty string or a full URL such as https://example.com. Anything else gets Zod's default URL message.
Which fields have a description?
Company ("Where do you work?") and website ("Your personal or company website."). The required fields have a label, the input and a FieldError.
API Reference
Field
Sets invalid={fieldState.invalid} and orientation="horizontal". The rest is on the Field page.
Input
Sets field, placeholder="John", placeholder="Doe", placeholder="john@example.com", type="email" and placeholder="Acme Inc". The rest is on the Input page.
Button
Sets type="submit". The rest is on the Button page.





