Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Field examples · Basic Inputs

Simple Input with Label Field for React

An email input with its label above it.

Framework
UI library

The basic field: a FieldLabel above an email Input, in a Field that keeps them together and spaced. Start here and add a FieldDescription or FieldError as the form needs them.

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 does the Email label connect to the input?

FieldLabel names the input. Its htmlFor matches the control's id. The label text is Email.

Why is the label above the input?

orientation defaults to vertical, so the label stacks over the control. Field sets data-orientation to that value.

Why is this input an email field?

type is email. The placeholder is you@example.com, and it clears once someone types.

How wide is the field?

max-w-md on Field caps the width. The label and the input both fill that width in the vertical layout.

How do I add a hint under the input?

Put FieldDescription after the Input. This demo is only the label and the input.

How do I show an error on this field?

Set invalid on Field when the value fails, and render the message with FieldError. The input still holds the value.