Forms

Text Field

A basic input field for entering short text, commonly used for forms, user input, and data entry. It supports validation, prefixes, suffixes, and various states.

Loading...

Installation

Install the component via the CLI in one command.

npx shadcn@latest add @intentui/text-field

Composed components

When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.

Manual installation

Use this approach if you prefer to install and wire up the component yourself instead of using the CLI.

npm install react-aria-components @heroicons/react

Anatomy

import { TextField } from "@/components/ui/text-field"

<TextField
  name="name"
  type="text"
  label="Name"
  description="Enter your name"
  placeholder="John Doe"
  errorMessage="This field is required"
  prefix="..."
  suffix="..."
/>

Examples

Prefix and suffix

Wrap Input with InputGroup to add prefix and suffix content.

Loading...

Suffix button

Wrap Input with InputGroup to add a button as the suffix.

Loading...

Revealable

When using a text field as a password input, you may want the option to reveal the password.

Loading...

Validation

In this example, we’ll ensure it’s treated as a strict requirement.

Loading...

Controlled

Manage the TextField value through the value prop for controlled usage.

Loading...

Uncontrolled

Manage the TextField value through the defaultValue prop for uncontrolled usage.

Loading...

Description

You can add a description to the text field by using the description prop.

Loading...

Readonly

Set the TextField to readonly, preventing any edits.

Loading...

Disabled

When the TextField is disabled, it becomes non-editable and appears inactive.

Loading...

Component API

TextField

The TextField component renders a labeled text input.

PropTypeDefault
classNamestring-

See the React Aria for the full API reference.

Unlock the full power of
Intent UI Design

Build modern web apps faster with 1000+ resources across components, blocks, patterns, templates, and starter kits.

Learn more