Launch sale — 60% off Pro
Contact
FormMulti Field

Not affiliated with official shadcn/ui. Visit ui.shadcn.com for official docs.

React Form with Optional Fields

A React form mixing required and optional fields using Zod optional validation with Optional suffix labels built with shadcn/ui and React Hook Form

Looking to implement shadcn/ui patterns?

Join our Discord community for help from other developers.


Not every form field deserves to be required. This React form uses Zod .optional() and .or with z.literal for company and website fields while requiring firstName, lastName, and email. Built with shadcn/ui Form components with React Hook Form and Optional label suffixes for clarity and grid layout for names, it's perfect for flexible registration, profile updates, or contact forms where some information is nice-to-have not mandatory.

Where do you work?

Your personal or company website.

Pattern created by @haydenbleasel

Installation

Questions you might have