# Input

> A single-line native text field with IME, selection and undo/redo.

- Category: [Inputs & forms](https://tarve.dev/docs.md#inputs)
- Import: `import { Input } from "@tarve/core";`
- Props type: `InputProps`
- Source: [packages/core/src/components/input.ts:33](https://github.com/omarcosr/tarve/blob/main/packages/core/src/components/input.ts#L33)

## Usage

```tsx title="Input.tsx"
import { Input } from "@tarve/core";

let email = "";

<Input
  type="email"
  value={email}
  placeholder="you@example.com"
  onChange={(value) => {
    email = value;
  }}
  onSubmit={(value) => console.log("submitted", value)}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `autoFocus` | `boolean` | — | Focus the field when it first appears (HTML `autofocus`), e.g. in a dialog that just opened. |
| `disabled` | `boolean` | — |  |
| `glass` | `GlassProp` | — | A Liquid Glass capsule field. |
| `maxLength` | `number` | — | The most characters the user can bring the value to (HTML `maxlength`): typing past it is dropped, a paste is cut to fit. |
| `onChange` | `(value: string) => void` | — |  |
| `onSubmit` | `(value: string) => void` | — | Enter (with or without modifiers) submits the current value. |
| `placeholder` | `string` | — |  |
| `readOnly` | `boolean` | — | Focusable, selectable and copyable, but the user cannot edit it (HTML `readonly`). The app can still change `value`. |
| `type` | `InputType` | `"text"` |  |
| `value` | `string` | — |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="GlassProp"
type GlassProp = boolean | GlassVariant | GlassOptions;
```

```ts title="InputType"
type InputType = "text" | "password" | "email" | "number" | "search" | "tel" | "url";
```

Previous: [SvgRect](https://tarve.dev/docs/components/SvgRect.md) · Next: [TextArea](https://tarve.dev/docs/components/TextArea.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Input · Index for agents: https://tarve.dev/llms.txt
