---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Text input

A single-line field for free words, such as a name, a title or an email, for React and Tailwind CSS. Free, MIT.

Free. Its export: `TextInput`.

## Try it

Type in it; switch every look and type (the time box is always a time), disabled, invalid and read-only.

Nothing is sent; the search bar's own field is tried on the search bar's page.

## When to use

- A single-line field for free words, such as a name, a title or an email.
- Also called: text field.

## When not to use

- For long text use Textarea, for a search SearchInput.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Text input on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

```sh
npx shadcn@4.23.1 add @goop/trail-text-input
```

```text
Add the Goop Text input to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { TextInput } from '@/components/ui/goop/text-input';

<>
  <TextInput variant="filled" aria-label="Your name" placeholder="Your name" />
  {/* a form's field: 32 px on a wide screen, 44 px on a phone */}
  <TextInput aria-label="Work email" type="email" />
  {/* a toolbar's 28 px field, level with a Button at size="md" */}
  <TextInput size="sm" aria-label="Filter" placeholder="Filter" />
</>
```

- Fits: account, settings, flow, schedule (their recipes).
- Also known as: Input.
- height, width, padding, corner, border, background, shadow, text, motion: add no class for these.

## API reference

### Options

- `variant: default | ghost | filled | title | unstyled | heading | heading-sm | search | search-outline | search-raised | time = default`
- `size: sm | md | lg = md`
- `type?: 'text' | 'email' | 'password' | 'search' | 'tel' | 'url'` — The input's own `type`; left out, `text` (`search` on the search looks); `variant="time"` forces `time`.
- `value?: string`
- `defaultValue?: string`
- `onChange?: (event: ChangeEvent<HTMLInputElement>) => void`
- `name?: string`
- `required?: boolean`
- `disabled?: boolean`
- `form?: string`

## Accessibility

- The native element answers the keyboard.
- hover, active, focus, focus-visible, focus-within: the browser's own (:hover, :active, :focus, :focus-visible, :focus-within): write nothing
- disabled: the prop disabled
- invalid: the attribute aria-invalid

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Textarea](/themes/trail/components/textarea): A multi-line field for free text, such as a description or a comment, that grows by rows as a person types.
- [Search input](/themes/trail/components/search-input): A search field with the search icon at its start, for narrowing a list or a page.
- [Password field](/themes/trail/components/password-field): A field for a password with a button that shows or hides the typed words, for sign-in, sign-up and reset forms.
- [Number input](/themes/trail/components/number-input): A field for a number, an amount or a quantity, typed in the reader's language or stepped with the arrow keys.
