---
title: "Input"
description: "A field for one line of text, such as a name or an email address. It comes in the 3 sizes of Button, with invalid, disabled, and read-only states."
url: https://gelatinui.com/components/input
markdown_url: https://gelatinui.com/components/input.md
access: free
install: "npx shadcn@latest add @gelatin-ui/input"
registry_item: https://gelatinui.com/r/input.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Input

> A field for one line of text, such as a name or an email address. It comes in the 3 sizes of Button, with invalid, disabled, and read-only states.

Page: https://gelatinui.com/components/input

## When to use it

Best for: One line of text in a form: an email address, a name, or a URL.

- Use it for one line of text: an email address, a name, a URL.
- Put it in a Field for its label, description, and error.
- Set `size` (28, 32, or 36px) to match the Button next to it. Set the width with `className`.

## When not to use it

- For a one-time code, use [Input OTP](https://gelatinui.com/components/input-otp.md).
- For many lines of text, use a multi-line text field, not an Input.

## Notes for agents

- Put it in a `Field` for its label, help, and error; alone it has no name.
- Match `size` to the Button next to it (28, 32, or 36px); set the width with `className`.

## Anatomy

```text
Input
```

## API reference

### Input

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` |  |  |
| `surface` | `"default" \| "group" \| "plain"` |  |  |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Input`: https://base-ui.com/react/components/input

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Input | `input` | `aria-invalid` |  | `status-colors` |

## Usage

Put the Input in a `Field` with a `FieldLabel`, so the label and the error link to it. `size` is the height (`sm` 28, `default` 32, `lg` 36px), not the native `size` attribute.

The sample also uses `field`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/input @gelatin-ui/field
```

```tsx title="workspace-url-field.tsx"
import { Field, FieldError, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";

export function WorkspaceUrlField() {
  return (
    <Field name="workspaceUrl">
      <FieldLabel>Workspace URL</FieldLabel>
      <Input type="url" size="lg" required autoComplete="url" placeholder="https://acme.dev" />
      <FieldError match="typeMismatch">Enter a full URL, with https://.</FieldError>
    </Field>
  );
}
```

## Compose

Build it with:

- [Form](https://gelatinui.com/components/form.md): Owns the submit and the errors.
- [Field](https://gelatinui.com/components/field.md): Names each control and shows its error text.
- [Textarea](https://gelatinui.com/components/textarea.md): Takes long text.
- [Stepper](https://gelatinui.com/components/stepper.md): Shows the steps of a long form.
- [Dialog](https://gelatinui.com/components/dialog.md): Holds a short form over the page.
- [Button](https://gelatinui.com/components/button.md): Submits or moves to the next step.
- [Alert](https://gelatinui.com/components/alert.md): Shows an error of the whole form.

Rules:

- Name every control (`label-every-control`): Give every field a visible `Label` (or a `Field`), and every icon button a `Tooltip` or an `aria-label`.
- Labels real apps use (`real-labels`): Write the button and menu labels that real apps use ("Create API key", "Invite members"), with no "…" at the end.
- No layout jump (`no-layout-jump`): When a state change adds, removes, or resizes content, reserve its space or animate its size, so nothing below it jumps.
- Touch targets (`touch-targets`): Give every control a hit area of at least 44 px on touch screens, even when it looks smaller.

Patterns: `gelatin://patterns/form-flow`

## Add it

```bash
npx shadcn@latest add @gelatin-ui/input
```

It adds 5 registry items: 2 files, 1149 lines, and the npm packages `@base-ui/react`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Field](https://gelatinui.com/components/field.md)
- [Form](https://gelatinui.com/components/form.md)
- [Input OTP](https://gelatinui.com/components/input-otp.md)
- [Textarea](https://gelatinui.com/components/textarea.md): Pick Textarea for many lines of text, such as a comment or a description.
- [Number Field](https://gelatinui.com/components/number-field.md): Pick Number Field for one number with steps and limits, minus and plus buttons, and number formats.

## Accessibility

Input is a Base UI `Input`, a native `<input>`. In a `Field`, `FieldLabel` names it, and Base UI links the help and the error with `aria-describedby`.

An invalid field (`aria-invalid`) shows a red edge and ring. Focus shows a 3px ring. A read-only field gets a muted fill.

The text stays 14px on phones. Add the `ios-viewport` script to the document head, so iOS does not zoom into a focused field.
