Skip to content

TextField

Stable

A single-line text box with room for an icon or unit, two sizes and an invalid state.

Also known as input, text input, textbox, text box

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Search with an icon

The icon is decorative. The box needs its own name because there is no visible label.

When to use it

A single line of text, email, link, phone number, search or password, with the same look and states as the other form controls.

Made of: Box · Leading slot · Input · Trailing slot

Use it for

  • A name, email, link or phone number in a form.
  • A search box with a search icon.
  • A value with a unit, such as a price with a currency sign.

Not for

  • A number the user steps up and down: use NumberField.
  • Picking one value from a fixed list: use Select.
  • Writing a message to the AI: use PromptBox.
  • A long, multi-line message with attachments and send: use Composer.

Do and avoid

Add the part after the @ sign.

Do. A red border plus words that say how to fix it.
Avoid. A red border alone does not say what is wrong.

Do

  • Wrap it in Field so it has a visible label.
  • Use the matching type so phones show the right keyboard.
  • Use leading for an icon and trailing for a unit.
  • Keep placeholder text as an example, not an instruction.

Avoid

  • Do not use a placeholder as the only label.
  • Do not show an invalid border without a message in text.
  • Do not use it for a number the user steps. Use NumberField.
  • Do not put a button in leading or trailing without giving the button its own label.

On a phone

  • It fills the width of its container and is 44px tall on touch screens, even at size sm.
  • Text is 16px on touch screens, so iPhones do not zoom in when the field gets focus.
  • The type prop picks the on-screen keyboard (email, tel, url, search), and extra attributes such as inputMode pass through to the input.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started