# <input>

A text field with a label, helper text, an icon and validation; type="code" draws one box per character.

Category: Forms and input.

```ham
<column style="gap-16 w-full">
    <input name="email"
           label="Email"
           icon="mail"
           helper="We'll send the receipt here."
           value="maya@example.com"/>
    <input name="otp"
           type="code"
           length="6"
           inputmode="numeric"/>
</column>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/input-light.webp), [dark](https://hypeapps.dev/img/tags/input-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `autocapitalize` | On-screen keyboard auto-capitalization, same vocabulary as HTML. (off, none, on, sentences, words, characters) | `off` |
| `enterkeyhint` | The label of the keyboard's return key, as in HTML. Return fires submit: action-submit / @on.submit, with $event.value. (enter, done, go, next, previous, search, send) |  |
| `error` | Custom error message for validation failures |  |
| `helper` | Helper text below input |  |
| `icon` | Prefix icon name |  |
| `inputmode` (also `input-mode`) | type="code": numeric takes digits only, with a number keyboard. (numeric) |  |
| `label` | Label (replaces placeholder as labelText when set) |  |
| `length` | type="code": how many characters (1–12). | `6` |
| `max` | Maximum value (number type) |  |
| `max-length` | Maximum character length |  |
| `min` | Minimum value (number type) |  |
| `min-length` | Minimum character length |  |
| `name` | Variable name for form scoping |  |
| `pattern` | Regex validation pattern |  |
| `placeholder` | Placeholder text |  |
| `required` | Require a non-empty value. A failing rule stops the form's request: the field shows its message and takes focus. | `false` |
| `style` | Style classes (bg-*, border-*, rounded-*, text-*, underlined, borderless, font-*) |  |
| `type` | Input type. code: one box per character (length=), auto-advance, paste fills all, letters upper-cased; filling the last box fires complete (\$event.value). (text, password, email, number, hidden, code) | `text` |
| `value` | Initial value |  |
| `variant` | outlined: a Material box with a floating label. underline: a hairline under the text. plain: no border and no floating label (the placeholder, or the label, is a hint), for a capsule you draw with style=. (outlined, underline, plain) | `outlined` |

## Commands

| Name | What it does |
|---|---|
| `blur` | Unfocus it (closes the keyboard). |
| `clear` | Empty it and its name= variable. |
| `focus` | Focus the field (opens the keyboard). |

## Readings

| Name | What it does |
|---|---|
| `error` | The validation message for the text; empty when valid. |
| `focused` | Whether the field has the keyboard focus. |
| `length` | How many characters are in the field, live. |
| `max_length` | The max-length= in force (a code input: its length=), in characters; empty when none. |
| `valid` | Whether the text passes the field's rules (required, min-length, pattern …); true with no rules. |
| `value` | The text in the field, live as it is typed. |

Any tag also takes gestures: `@on.tap`, `@on.longpress`, `@on.doubletap` and `@on.swipeleft` (and right, up and down). `@click` runs on a tap too.

## Guides and recipes that use it

- [Forms and state](https://hypeapps.dev/docs/guides/forms.md)
- [Lists and loops](https://hypeapps.dev/docs/guides/lists.md)
- [Data and databases](https://hypeapps.dev/docs/guides/data.md)
- [Who's using the app ($me)](https://hypeapps.dev/docs/guides/me.md)
- [Your own tags](https://hypeapps.dev/docs/guides/own-tags.md)
- [A chat thread](https://hypeapps.dev/docs/cookbook/chat.md)
- [Search on the server (MoviePlz)](https://hypeapps.dev/docs/cookbook/movieplz-search.md)

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<button>`](https://hypeapps.dev/docs/reference/button.md): A tappable button that runs an action: a fetch, a navigation or a statement.
- [`<checkbox>`](https://hypeapps.dev/docs/reference/checkbox.md): A checkbox with a label; its state goes into a variable by name.
- [`<chip>`](https://hypeapps.dev/docs/reference/chip.md): A compact chip: a label, a filter that toggles, a single choice in a set, or an action.
- [`<color-picker>`](https://hypeapps.dev/docs/reference/color-picker.md): A color picker: a hue ring round a disc, with swatches; the chosen color goes into a variable.
- [`<data-cell>`](https://hypeapps.dev/docs/reference/data-cell.md): One cell of a data table row.
- [`<data-column>`](https://hypeapps.dev/docs/reference/data-column.md): A column heading of a data table.
- [`<data-row>`](https://hypeapps.dev/docs/reference/data-row.md): One row of a data table, holding a data cell for each column.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
