Skip to content
SENVENLI UI

Input

One text-entry field with a label, description and error; `type` picks text, email, url, password, search, number or tel.
A labeled field
import { Input } from "@senvenli/react/form";

Examples

Prefix and suffix

An icon, a unit or a URL part inside the frame.

Invalid

The error says what happened and what to do.

Small, read-only and disabled

The smaller size for dense forms, and the two states a value can be locked in.

Password: Signing in

`current-password` lets the password manager fill it; the button shows or hides the value.

Password: Creating a password

The requirements up front, and a strength meter while typing.

Password: Invalid

The error says what to do next.

Search: Search a list

The placeholder lists what can be searched; `aria-label` names the field.

Search: Filtering as you type

Controlled: the list follows the text, and Esc or the clear button empties it.

Search: Label, shortcut and small size

A visible label, and a key hint shown while the field is empty.

Number: A quantity

The stepper suits small whole numbers; the range is stated up front.

Number: Money

`currency` adds the symbol and keeps the currency's decimals.

Number: Units and percentages

A suffix for a unit, or `formatOptions` when Intl can print it.

Phone: A phone number

Opens on `defaultCountry`; the suggested countries lead the list.

Phone: Controlled

The value is E.164; `onChange` also gives the chosen country.

Phone: Invalid

The error says what a full number looks like.

Guidelines

When to use it

  • Short free text: a name, an email, a code.
  • Entering or creating a password.
  • Searching or filtering a list or the app.
  • Entering a number: a quantity, a price, a percentage.
  • Any phone number a person types: sign-up, checkout, contact details.

Use something else when

Do and avoid

  • Errors say what happened and what to do: "Enter a valid email: name@example.com".

Accessibility

Keyboard

KeysWhat happens
EscapeClears the field.
EnterSubmits the search.
Arrow up / downIncrements or decrements by the step.
Arrow downOpens the country list from the country button.
TypeSearches countries by name or calling code.

Built in

  • Label, description and error are announced with the input.
  • Required fields show "Fill in this field." after a blur or a submit; your own errorMessage replaces it.
  • The toggle is named "Show password" / "Hide password".
  • Password managers can fill it.
  • The clear button is named "Clear".
  • Steppers are named "Increase" and "Decrease".
  • Formats and parses in the user's locale.
  • The country button is named with the country and its code.
  • Too short and too long say so in words.
  • Required fields show "Fill in this field."

You provide

  • A visible label.
  • A label or placeholder that lists what can be searched.
  • The range in the label or description.
  • suggestedCountries for the markets the form expects.

API reference

Input

autoCapitalize
"off" | "none" | "on" | "sentences" | "words" | "characters" | (string & {})

Mobile keyboards' capitalization: none for e-mail and codes, characters for codes, words for names. React Aria's TextField forwards it to the input (useTextField reads it); its types leave it out, so it is declared here.

aria-invalid
boolean | "true" | "false"

Set by a form row that owns the error text (the shared Field hands its control aria-invalid): the field shows its invalid state as with isInvalid, and without an errorMessage of its own draws no error row, so the row's message is the only one. It marks the input for assistive tech and draws it invalid only: unlike isInvalid it never becomes the input's native validity, so it never blocks a form's submit, and the field's own validation runs as without it.

variant
"text" | "numeric" | "code"

code for codes, references and IDs; numeric for money, distance and counts.

step
string | number | number
size
FieldSize
label
React.ReactNode

Always given; the label sits above the field, never inside it.

description
React.ReactNode
errorMessage
React.ReactNode

What happened and what to do ("Enter a valid email: name@example.com").

requiredValidation
RequiredValidation

Who says an empty required field is missing: field (default) or app. With app a DS Form's onSubmit runs with the field empty, and the app's own error must clear on change. See {@link RequiredValidation} for the whole contract.

isOptional
boolean

Shows "(optional)" when most of the form is required.

max
string | number
min
string | number

Bounds and step for type="number"; prefer NumberField for money and counts that need formatting.

placeholder
string
leading
React.ReactNode

Before the value, inside the frame: text, a unit or currency ("€", "https://"), or <Icon name="search" />.

trailing
React.ReactNode

After the value, inside the frame: a unit ("kg"), a domain, an icon.

actions
React.ReactNode

Extra controls at the end of the frame (InputAction).

displayCase
"uppercase"

uppercase shows the value in capitals (a code: "ab 123" reads "AB 123"); display only . The input's value, onChange and the submitted form value stay exactly as typed; the caret and selection follow the text as drawn. Capitals follow the page's language, as CSS text-transform does (lang="tr": "i" shows as "İ"), the same as toLocaleUpperCase in that locale. The placeholder keeps its own case. Normalise the stored value in the app if it must be capitals.

valueDir
"inherit" | "ltr"

ltr keeps the frame, addons and value, left to right on an RTL page: phone numbers, IBANs and card numbers read LTR in every locale ("ME +382 67 412 908", never "908 412 67 ME +382"). The label, help text and error still follow the page. On by default for type url, email and tel (the placeholder then aligns LTR too); inherit turns that off and follows the page. Pass ltr for a domain with URL addons: "https://shop.example.com", never "com. shop.example //:https".

type
"text" | "url" | "email" | "password" | "search" | "number" | "tel"

text (default), email or url: the matching keyboard and autofill on phones.

radius
ComponentRadius

Corner radius: none, small, medium (the design), large or full. The provider's default otherwise.

showStrength
boolean

Four-segment meter with a word under it (create and reset only).

isRevealed
boolean

Controlled visibility: true shows the value as text. Leave it out for the default, where the show / hide button alone decides; set it when the app writes a value the person should see (a "Generate" button).

onRevealChange
(revealed: boolean) => void

Called with the next visibility when the show / hide button is pressed.

shortcut
string

A key hint shown at rest ("/"); the app binds the key.

showStepper
boolean

The stepper on the end, for small integers.

currency
string

Money: an ISO 4217 code ("EUR"). The symbol becomes a leading addon and the amount keeps two decimals, which reads as the design's "€ 248,00" (symbol first, with a space); Intl's own currency style has no space in tr / me.

locale
string

Formats and parses in this locale instead of the provider's (the branch locale).

country
string

Controlled ISO country. Left out, it is read from the value, then defaultCountry. A shared calling code reads back as the table's first country for it (+1 → US): pass country to keep Canada.

defaultCountry
string

The country an empty field opens on; by default the locale's region ("de-AT" → AT, "en" → US).

suggestedCountries
readonly string[]

ISO codes shown first, above "All countries" (the markets this form expects).

onUnsupportedInternationalPaste
(pasted: string) => void

A pasted international number whose country is not offered; the value stays unchanged.

labels
{ country?: (country: string, callingCode: string) => string; countryList?: string; countrySearch?: string; countryEmpty?: (query: string) => React.ReactNode; suggestedCountries?: string; allCountries?: string; }

The field's words, already localized; the DS strings in the provider locale by default: - country: the country button's name, from the country's name and calling code ("Country: Germany, +49"); - countryList: the country list's name, also its popover's ("Country"); - countrySearch: the country search box's name ("Search countries"); - countryEmpty: the list's empty result for the typed search ("No results for “{query}”."); - suggestedCountries: the first section's name, the suggestedCountries ("Suggested countries"); - allCountries: the header above the rest when suggestions show ("All countries").

Also takes 88 standard DOM and ARIA attributes (id, aria-label, event handlers…).