Vigyata.AI
Is this your channel?

I Never Want To Create Forms Any Other Way

32.3K views· 951 likes· 57:53· Jul 1, 2023

🛍️ Products Mentioned (4)

Today I will show you how to build the perfect form in react with typescript. Featuring a fully type safe user validation experience with zod and react-hook-form. Beautifully styled with shadcn and tailwindcss, also featuring a dark mode toggle :) Project Code: https://github.com/Elliott-Chong/shadcn-form-yt My GitHub: https://github.com/Elliott-Chong Shadcn UI: https://ui.shadcn.com/ My Website: https://elliottchong.tech 0:00 Intro & Demo 1:35 Initialize NextJS project 2:40 What is shadcn? 3:38 What is RadixUI? 4:27 Begin coding 5:48 Initialize shadcn 7:22 Installing button from shadcn 9:15 Building dark mode toggle 15:46 Begin building form 20:10 Zod and react-hook-form 27:00 Form UI 34:45 Custom zod error messages 38:00 Begin building multi step form 50:10 Animation with framer-motion

About This Video

In this video I’m building what I consider the “perfect” modern React form: fully type-safe, properly validated, and actually nice to use. I start from a fresh Next.js + TypeScript project, set up Tailwind, and then pull in shadcn/ui the way it’s meant to be used—copy-paste components into your codebase so you own them. I also explain what shadcn is (not a typical component package) and why it works so well on top of Radix UI primitives. From there I wire up dark mode properly with next-themes (light/dark/system), including a reusable theme toggle component (and I show a best-practice pattern for passing className instead of hardcoding layout). Then we get into the form itself: react-hook-form for performant form state, Zod for schema validation, and the resolver glue that makes the whole thing type-safe end-to-end. I define a register schema (email, name, student ID, year, password, confirm password), set defaultValues with full TypeScript inference, add custom error messages, and finally turn it into a multi-step form with smooth transitions using framer-motion—where you literally can’t advance until the current step is valid.

Frequently Asked Questions

🎬 More from Elliott Chong