Skip to content

Input

Get Ritla UI

A text field with a visible label and helper text, with the states every Ritla UI field shares: enabled, hover, focus, error, disabled, read-only and auto-fill.

Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add input

    Also works with shadcn: npx shadcn@latest add @ritla/input

  2. Dependencies it brings

    @base-ui/react@phosphor-icons/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

input.tsx
import { Input } from "@/components/ui/input";<Input label="Full name" required name="name" autoComplete="name" helperText="We use it on your receipts." />

Examples

States

An empty field is gray, a filled one white. error with a message replaces the helper text and sets aria-invalid. Hover, focus and auto-fill come from the browser.

EnglishMirroredArabic
LTR →

Leading and trailing content

leadingIcon and prefix at the start, suffix, trailingIcon and status at the end; they swap sides in Arabic. In dir="ltr" fields (emails, URLs) the row stays left to right.

EnglishMirroredArabic
LTR →

Text in either language

The field takes dir="auto": each value runs in its own direction, so an English sentence in an Arabic form keeps its punctuation at the end. Emails, URLs and codes are always left to right: pass dir="ltr".

EnglishMirroredArabic
LTR →

API reference

Input

Also takes every <input> prop (type, name, value, placeholder, autoComplete, inputMode…).

PropTypeDefaultDescription
labelReactNodeNoneFigma's Label. Required and always visible.
requiredbooleanfalseFigma's Required: the asterisk and required on the input.
helperTextReactNodeNoneFigma's Helper text.
errorReactNode | booleanNoneState = Error. A message replaces the helper text; true turns the helper text into the error.
disabledbooleanfalseState = Disabled.
readOnlybooleanfalseState = Read-only.
leadingIconIconComponentNone_Leading content, Type Icon.
prefixReactNodeNone_Leading content, Type Text only or Currency.
suffixReactNodeNone_Trailing content, Type Text.
trailingIconIconComponentNone_Trailing content, Type Icon.
shortcutReactNode[]NoneShortcut keys at the end of the field (Input group). A hint only: put aria-keyshortcuts on the input.
actionReactNodeNoneA button at the end of the field (Input group, Trailing icon), such as copying the value.
status"success" | "loading" | "warning" | "error" | "disabled"NoneShow Field Status. Decorative: say the status in the helper text too.

Usage guidelines

An input field collects short text with a visible label and helper text. Which field to pick, how to write labels and errors, how left-to-right data stays that way, and the checks before handoff.

1. Pick the right field

Use the most specific field for the data. Each one brings the keyboard, formatting, validation and autocomplete that fit: the phone field formats numbers per country, card details check the card number, the code field accepts a pasted SMS code.

DataUseWhat it adds
Short text: a name, an email, a cityInput fieldLabel, helper, states; set the input type (email, url) and autocomplete in code.
A phone numberPhone number fieldCountry selector, formatting as you type, E.164 value, Arabic-Indic digits accepted.
A quantity or an amountNumber inputSteppers, arrow keys, clamping, numerals from the numerals setting, optional currency prefix.
A passwordPassword inputShow and hide; a strength meter on sign-up.
A one-time code from SMS or emailVerification code4 to 6 boxes, paste and autofill of the whole code.
Card number, expiry and CVVCard detailsOne group, formatting, network detection, Luhn check, browser card autofill.
Several lines of textText areaGrows with the text and shows a counter.
One choice from a listSelectA menu of options instead of free typing.

Use the dedicated field

A mobile number in a sign-up form.

Do: Phone number fieldCountry, calling code and formatting come with it, and the value is stored in one standard form.
Don't: Plain text fieldPeople type 07…, +962… or 00962… and the product has to untangle it.

2. Label, placeholder and helper

Every field has a visible label above it that names the data. The placeholder is only an example of the format and disappears when people type, so it never replaces the label. Helper text under the field explains what the label can't: format, limits, why you ask.

Label above, example inside

An email field.

Do: Visible label and helperThe label stays while typing; the helper says why the email is needed.
Don't: Placeholder as labelOnce people start typing, nothing says what the field is for.

Do

  • Write short noun labels: Email, Mobile number, Date of birth.
  • Use the placeholder for an example of the format, or leave it empty.
  • Put format rules and reasons in the helper text, before people make a mistake.
  • Mark the few optional fields as optional when most are required, or the reverse.

Don't

  • Use a placeholder instead of a label.
  • Put instructions in the placeholder; they vanish on the first keystroke.
  • End labels with a colon.
  • Write the label as a question when a noun works.

3. Errors

Validate when people leave a field or submit the form, not on every keystroke. Show the message under the field in the Error state, say what went wrong and how to fix it, and keep what they typed. The message replaces the helper text while the error lasts.

Say how to fix it

An email with a missing domain.

Do: Specific messageThe message names the problem and shows a valid example.
Don't: Generic message“Invalid input” says something is wrong, not what or how to fix it.

Do

  • Say how to fix it: “Enter an email like name@example.com”.
  • Keep the typed value so people can correct it.
  • Move focus to the first field in error after a failed submit.
  • Use the Error state and the message together; color alone isn't enough.

Don't

  • Show generic messages like “Invalid input” or “Error”.
  • Clear the field when it fails validation.
  • Show errors before people have finished typing.
  • Blame the user: “You entered a wrong email”.

4. Arabic, and data that stays left to right

On Arabic screens use the RTL variants: the label, helper and text align right and use IBM Plex Sans Arabic. Some data is written left to right in every language: emails, web addresses, phone numbers, card numbers, codes and IDs. Those inputs stay LTR inside an RTL form (in Figma, Latin input = Yes on the _Input; in code, dir="ltr" on the input). Text people type freely gets dir="auto", so an English answer in an Arabic form still reads correctly.

Arabic field, left-to-right data

An email being typed in an Arabic sign-up form.

Do: RTL variant, LTR emailLabel and helper read right to left; the address reads as it is written.
Don't: English variant with Arabic labelThe Arabic label sits on the left in a Latin font, and the form no longer lines up.

5. Width and layout

Stack fields in one column with the label above. Size each field to the data it expects: a postal code or a CVV is short, an email or an address is long. Group fields that belong together (card details, a date range) and keep space-24 between fields.

Width hints at the answer

The address part of a checkout form.

Do: Sized to contentThe short field tells people a short answer is expected.
Don't: Everything full widthA full-width postal code looks like it wants a whole address.

Do

  • Use one column; people read forms top to bottom.
  • Match the width to the expected length of the answer.
  • Put short related fields side by side: city and postal code.

Don't

  • Make every field full width regardless of its content.
  • Put unrelated fields side by side to save space.
  • Place labels beside the field; Arabic labels vary too much in length.

6. Read-only, disabled and auto-fill

Read-only shows a value people can read and copy but not change, such as an account number; it keeps full contrast. Disabled means the field doesn't apply right now; its text is dimmed and screen readers may skip it. Auto-fill is the tint the browser adds when it fills a field; keep it, so people can check what was filled.

Read-only for values to keep

An IBAN on a payout settings screen.

Do: Read-onlyFull contrast, selectable, clearly not editable.
Don't: DisabledDimmed text is hard to read and can't be selected to copy.

Do

  • Use Read-only for values people need to see or copy.
  • Explain a disabled field in its helper text, or hide it.
  • Keep the auto-fill tint until people edit the field.

Don't

  • Use Disabled for information people need to read.
  • Style a read-only value as a normal editable field.

7. Passwords, codes and cards

These fields handle sensitive data, so they lean on the browser and the operating system: autocomplete fills them, password managers save them, and SMS codes arrive by themselves. Set the right autocomplete in code and don't fight the defaults.

Do

  • Offer show and hide on every password field.
  • Show the strength meter only when people create a password, with your own scoring.
  • Let people paste a whole verification code; code fills every box at once.
  • Keep card details as one group: number, expiry, CVV, in that order.
  • Set autocomplete: current-password, new-password, one-time-code, cc-number.

Don't

  • Block paste in password or code fields.
  • Ask people to confirm a password in a second field when show and hide is there.
  • Split a card number into four separate fields.
  • Show password rules only after a failed attempt; put them in the helper text.

Before handoff

  • Each field uses the most specific component for its data.
  • Every field has a visible label; placeholders only show a format.
  • Error messages are written for every validation rule.
  • Arabic screens use RTL variants, with LTR data kept LTR.
  • Widths match the expected answers, in one column.
  • Autocomplete values are noted for development.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
TabMoves focus to the field: its border turns dark blue with a soft halo around it (a red halo when invalid), and a focus outline shows in high-contrast mode.

ARIA

  • The <label> is tied to the input, and the helper text or error through aria-describedby.
  • An error sets aria-invalid, and a new error message is read out politely (aria-live="polite").
  • The asterisk is decorative; required on the input is what's announced.
  • Use the right type, inputMode and autoComplete (email, tel, numeric).

Do

  • A visible label on every field; it is the accessible name.
  • The Error state with a message, wired through aria-describedby and aria-invalid.
  • 48 px height and the full focus ring, not clipped by a scroll area.
  • Tab follows the visual order in both directions.

Don't

  • Rely on the red border alone.
  • Hide the label visually without an accessible name.
  • Time out a form while people are typing.

Arabic and RTL notes

Mirrors

  • The label, helper text and leading icon sit at the inline start (the right), the status and suffix at the end.
  • Directional icons mirror.

Does not mirror

  • With dir="ltr" (emails, URLs, codes) the whole field row runs left to right, like Figma's phone field: “https://” stays before the value and “.ritla.app” after it.
  • Status icons don't mirror.
Numerals
What people type stays as typed. For numbers use Number Input, which follows numerals.
Arabic typography
Text is label-16, the label and helper label-12, with taller Arabic line heights; the 48px field fits both.
Mixed-direction text
The input takes dir="auto" by default, so each value runs in its own language's direction.

Do

  • The RTL variant for every field on an Arabic screen.
  • Keep emails, URLs, phone and card numbers and codes left to right (Latin input = Yes in Figma, dir="ltr" in code).
  • Accept Arabic-Indic digits in number, phone, code and card fields; code converts them to 0123456789.
  • Write labels and helper text natively in Arabic, not translated.

Don't

  • Arabic labels in the English variant.
  • Right-align an email or a phone number inside an RTL field.
  • Ask people to switch keyboards to type digits.

Checks it passes

The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.

  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space