Input
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
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add inputAlso works with shadcn:
npx shadcn@latest add @ritla/inputDependencies it brings
@base-ui/react@phosphor-icons/reactOr 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
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.
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.
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".
API reference
Input
Also takes every <input> prop (type, name, value, placeholder, autoComplete, inputMode…).
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | None | Figma's Label. Required and always visible. |
required | boolean | false | Figma's Required: the asterisk and required on the input. |
helperText | ReactNode | None | Figma's Helper text. |
error | ReactNode | boolean | None | State = Error. A message replaces the helper text; true turns the helper text into the error. |
disabled | boolean | false | State = Disabled. |
readOnly | boolean | false | State = Read-only. |
leadingIcon | IconComponent | None | _Leading content, Type Icon. |
prefix | ReactNode | None | _Leading content, Type Text only or Currency. |
suffix | ReactNode | None | _Trailing content, Type Text. |
trailingIcon | IconComponent | None | _Trailing content, Type Icon. |
shortcut | ReactNode[] | None | Shortcut keys at the end of the field (Input group). A hint only: put aria-keyshortcuts on the input. |
action | ReactNode | None | A button at the end of the field (Input group, Trailing icon), such as copying the value. |
status | "success" | "loading" | "warning" | "error" | "disabled" | None | Show 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.
| Data | Use | What it adds |
|---|---|---|
| Short text: a name, an email, a city | Input field | Label, helper, states; set the input type (email, url) and autocomplete in code. |
| A phone number | Phone number field | Country selector, formatting as you type, E.164 value, Arabic-Indic digits accepted. |
| A quantity or an amount | Number input | Steppers, arrow keys, clamping, numerals from the numerals setting, optional currency prefix. |
| A password | Password input | Show and hide; a strength meter on sign-up. |
| A one-time code from SMS or email | Verification code | 4 to 6 boxes, paste and autofill of the whole code. |
| Card number, expiry and CVV | Card details | One group, formatting, network detection, Luhn check, browser card autofill. |
| Several lines of text | Text area | Grows with the text and shows a counter. |
| One choice from a list | Select | A menu of options instead of free typing. |
Use the dedicated field
A mobile number in a sign-up form.
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
- 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
- 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.
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
- 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
- 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.
| Key | Action |
|---|---|
| Tab | Moves 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 througharia-describedby. - An error sets
aria-invalid, and a new error message is read out politely (aria-live="polite"). - The asterisk is decorative;
requiredon the input is what's announced. - Use the right
type,inputModeandautoComplete(email, tel, numeric).
Do
- A visible label on every field; it is the accessible name.
- The Error state with a message, wired through
aria-describedbyandaria-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 helperlabel-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 = Yesin 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.
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space