Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Field examples · Basic Inputs

Input with Description Above Field for React

A password input with its requirement stated between the label and the input.

Framework
UI library

Tell people the rule before they type. The FieldDescription sits between the Password label and the input, so the requirement is read before the field, not after a failed attempt. Use it for passwords, formats and anything with a constraint.

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

Why is the rule above the password box?

FieldDescription sits between FieldLabel and Input, so Must be at least 8 characters long is visible before typing. The label still comes first.

How is the password masked?

type is password, so typed characters stay masked. The placeholder is a row of asterisks, and the rule above it stays readable.

How does the Password label connect?

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

Is this field horizontal?

No. orientation is unset, so it stays vertical: label, description, then input. max-w-md caps the width.

How do I show a failure separately from the rule?

Keep the 8 character rule in FieldDescription. Set invalid on Field and render the failure with FieldError.

How do I move the rule under the input?

Put FieldDescription after the Input. That order suits a hint people can read while the value is already filled.