Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Tabs examples · Content

Tabs with Forms for React

Login and Register tabs that each hold a short form, splitting the list into two equal halves.

Framework
UI library

Sign in and sign up are two forms people choose between, so they can share one box. Login has Email and Password, and Register adds Full Name and Bio, each laid out with FieldGroup and Field. Use it in an auth page or dialog where both forms belong side by side.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How do Login and Register share the width?

TabsList has grid w-full grid-cols-2, so each trigger takes half. Login is the default, and the group is w-full max-w-md.

Which fields are in each form?

Login has Email and Password. Register has Full Name, Email, Password and Bio. Bio is a Textarea, and the rest are inputs with type set to text, email or password.

How are the labels tied to the inputs?

Each pair sits in a Field with a FieldLabel. Each FieldLabel points at its input's id, such as login-email and register-bio.

What happens on submit?

Both forms call one handler that prevents the default submit, so the page does not reload. Sign In and Create Account are full-width submit buttons. Read the form data and send it in that handler.

Do typed values survive a switch to the other tab?

No. Inactive panels unmount, so the inputs reset when you come back. Set keepMounted on each TabsContent to keep what was typed.

Why does the register panel say Create Account?

The trigger says Register, and the panel heading says Create Account with a line asking for the details. Login's heading matches its trigger.