import { Input } from "@senvenli/react/form";
export default function Example() {
return (
<Input
label="Work email"
type="email"
autoComplete="email"
placeholder="name@example.com"
description="We send invoices and receipts here."
/>
);
}import { Input } from "@senvenli/react/form";Examples
Prefix and suffix
An icon, a unit or a URL part inside the frame.import { Icon } from "@senvenli/react/display";
import { Input } from "@senvenli/react/form";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack space="space-200">
<Input label="Customer" leading={<Icon name="user" />} defaultValue="Ada Lovelace" />
<Input label="Workspace URL" leading="https://" trailing=".example.com" valueDir="ltr" defaultValue="acme" />
<Input label="Hourly rate" variant="numeric" inputMode="decimal" leading="$" trailing="per hour" defaultValue="85.00" />
</Stack>
);
}Invalid
The error says what happened and what to do.import { Input } from "@senvenli/react/form";
export default function Example() {
return (
<Input
label="Work email"
type="email"
defaultValue="ada@example"
isInvalid
errorMessage="Enter a valid email: name@example.com"
/>
);
}Small, read-only and disabled
The smaller size for dense forms, and the two states a value can be locked in.import { Input } from "@senvenli/react/form";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack space="space-200">
<Input label="Reference" size="small" variant="code" defaultValue="INV-2041" />
<Input label="Customer ID" variant="code" defaultValue="cus_8f3k2" isReadOnly />
<Input label="Company" defaultValue="Analytical Engines Ltd" isDisabled />
</Stack>
);
}Password: Signing in
`current-password` lets the password manager fill it; the button shows or hides the value.import { Input } from "@senvenli/react/form";
export default function Example() {
return <Input type="password" label="Password" autoComplete="current-password" />;
}Password: Creating a password
The requirements up front, and a strength meter while typing.import { Input } from "@senvenli/react/form";
export default function Example() {
return (
<Input type="password"
label="New password"
autoComplete="new-password"
description="At least 10 characters, with a number and a symbol."
showStrength
defaultValue="orchid-ladder"
/>
);
}Password: Invalid
The error says what to do next.import { Input } from "@senvenli/react/form";
export default function Example() {
return (
<Input type="password"
label="Password"
autoComplete="current-password"
defaultValue="orchid-ladder"
isInvalid
errorMessage="That password is not right. Try again or reset it."
/>
);
}Search: Search a list
The placeholder lists what can be searched; `aria-label` names the field.import { Input } from "@senvenli/react/form";
export default function Example() {
return <Input type="search" aria-label="Search customers" placeholder="Name, email or order number" />;
}Search: Filtering as you type
Controlled: the list follows the text, and Esc or the clear button empties it.import { Text } from "@senvenli/react/display";
import { Input } from "@senvenli/react/form";
import { Stack } from "@senvenli/react/layout";
import { useState } from "react";
const CUSTOMERS = ["Ada Lovelace", "Alan Turing", "Grace Hopper", "Katherine Johnson", "Margaret Hamilton"];
export default function Example() {
const [query, setQuery] = useState("");
const matches = CUSTOMERS.filter((name) => name.toLowerCase().includes(query.trim().toLowerCase()));
return (
<Stack space="space-150">
<Input type="search" aria-label="Search customers" placeholder="Customer name" value={query} onChange={setQuery} />
{matches.length > 0 ? (
<Stack as="ul" space="space-050">
{matches.map((name) => (
<li key={name}>
<Text>{name}</Text>
</li>
))}
</Stack>
) : (
<Text tone="subtle">No customers match “{query}”.</Text>
)}
</Stack>
);
}Search: Label, shortcut and small size
A visible label, and a key hint shown while the field is empty.import { Input } from "@senvenli/react/form";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack space="space-200">
<Input type="search" label="Search invoices" placeholder="Number, customer or amount" shortcut="/" />
<Input type="search" aria-label="Search projects" placeholder="Project name" size="small" />
</Stack>
);
}Number: A quantity
The stepper suits small whole numbers; the range is stated up front.import { Input } from "@senvenli/react/form";
export default function Example() {
return <Input type="number" label="Seats" description="1–50 seats per workspace." defaultValue={5} minValue={1} maxValue={50} showStepper />;
}Number: Money
`currency` adds the symbol and keeps the currency's decimals.import { Input } from "@senvenli/react/form";
export default function Example() {
return <Input type="number" label="Invoice amount" currency="USD" defaultValue={1248.5} minValue={0} />;
}Number: Units and percentages
A suffix for a unit, or `formatOptions` when Intl can print it.import { Input } from "@senvenli/react/form";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack space="space-200">
<Input type="number" label="Payment terms" trailing="days" defaultValue={30} minValue={0} maxValue={90} description="0–90 days after the invoice date." />
<Input type="number" label="Discount" formatOptions={{ style: "percent" }} defaultValue={0.15} minValue={0} maxValue={1} isOptional />
</Stack>
);
}Phone: A phone number
Opens on `defaultCountry`; the suggested countries lead the list.import { Input } from "@senvenli/react/form";
export default function Example() {
return (
<Input type="tel"
label="Phone number"
name="phone"
defaultCountry="US"
suggestedCountries={["US", "CA", "GB"]}
description="We only call about a delivery."
/>
);
}Phone: Controlled
The value is E.164; `onChange` also gives the chosen country.import { Text } from "@senvenli/react/display";
import { Input } from "@senvenli/react/form";
import { Stack } from "@senvenli/react/layout";
import { useState } from "react";
export default function Example() {
const [phone, setPhone] = useState("+442079460958");
const [country, setCountry] = useState("GB");
return (
<Stack space="space-150">
<Input type="tel"
label="Billing phone"
value={phone}
country={country}
suggestedCountries={["US", "CA", "GB"]}
onChange={(value, nextCountry) => {
setPhone(value);
setCountry(nextCountry);
}}
/>
<Text size="body-small" tone="subtle">
Stored as {phone || "nothing yet"} ({country})
</Text>
</Stack>
);
}Phone: Invalid
The error says what a full number looks like.import { Input } from "@senvenli/react/form";
export default function Example() {
return (
<Input type="tel"
label="Phone number"
defaultCountry="US"
suggestedCountries={["US", "CA", "GB"]}
defaultValue="+1415555"
isInvalid
errorMessage="Enter the full number with its area code: (415) 555-0132."
/>
);
}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
- The text may run to several lines. Text area
Do and avoid
- Errors say what happened and what to do: "Enter a valid email: name@example.com".
Accessibility
Keyboard
| Keys | What happens |
|---|---|
| Escape | Clears the field. |
| Enter | Submits the search. |
| Arrow up / down | Increments or decrements by the step. |
| Arrow down | Opens the country list from the country button. |
| Type | Searches 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
errorMessagereplaces 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
| Prop | Type | Default | Description |
|---|---|---|---|
autoCapitalize | "off" | "none" | "on" | "sentences" | "words" | "characters" | (string & {}) | – | Mobile keyboards' capitalization: |
aria-invalid | boolean | "true" | "false" | – | Set by a form row that owns the error text (the shared |
variant | "text" | "numeric" | "code" | – |
|
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: |
isOptional | boolean | – | Shows "(optional)" when most of the form is required. |
max | string | number | – | |
min | string | number | – | Bounds and step for |
placeholder | string | – | |
leading | React.ReactNode | – | Before the value, inside the frame: text, a unit or currency ("€", "https://"), or |
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 ( |
displayCase | "uppercase" | – |
|
valueDir | "inherit" | "ltr" | – |
|
type | "text" | "url" | "email" | "password" | "search" | "number" | "tel" | – |
|
radius | ComponentRadius | – | Corner radius: |
showStrength | boolean | – | Four-segment meter with a word under it (create and reset only). |
isRevealed | boolean | – | Controlled visibility: |
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 | 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: - |
autoCapitalize"off" | "none" | "on" | "sentences" | "words" | "characters" | (string & {})Mobile keyboards' capitalization:
nonefor e-mail and codes,charactersfor codes,wordsfor names. React Aria's TextField forwards it to the input (useTextField reads it); its types leave it out, so it is declared here.aria-invalidboolean | "true" | "false"Set by a form row that owns the error text (the shared
Fieldhands its controlaria-invalid): the field shows its invalid state as withisInvalid, and without anerrorMessageof 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: unlikeisInvalidit 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"codefor codes, references and IDs;numericfor money, distance and counts.stepstring | number | numbersizeFieldSizelabelReact.ReactNodeAlways given; the label sits above the field, never inside it.
descriptionReact.ReactNodeerrorMessageReact.ReactNodeWhat happened and what to do ("Enter a valid email: name@example.com").
requiredValidationRequiredValidationWho says an empty required field is missing:
field(default) orapp. Withappa DS Form'sonSubmitruns with the field empty, and the app's own error must clear on change. See {@link RequiredValidation} for the whole contract.isOptionalbooleanShows "(optional)" when most of the form is required.
maxstring | numberminstring | numberBounds and step for
type="number"; prefer NumberField for money and counts that need formatting.placeholderstringleadingReact.ReactNodeBefore the value, inside the frame: text, a unit or currency ("€", "https://"), or
<Icon name="search" />.trailingReact.ReactNodeAfter the value, inside the frame: a unit ("kg"), a domain, an icon.
actionsReact.ReactNodeExtra controls at the end of the frame (
InputAction).displayCase"uppercase"uppercaseshows the value in capitals (a code: "ab 123" reads "AB 123"); display only . The input's value,onChangeand the submitted form value stay exactly as typed; the caret and selection follow the text as drawn. Capitals follow the page's language, as CSStext-transformdoes (lang="tr": "i" shows as "İ"), the same astoLocaleUpperCasein that locale. The placeholder keeps its own case. Normalise the stored value in the app if it must be capitals.valueDir"inherit" | "ltr"ltrkeeps 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 fortypeurl,emailandtel(the placeholder then aligns LTR too);inheritturns that off and follows the page. Passltrfor a domain with URL addons: "https://shop.example.com", never "com. shop.example //:https".type"text" | "url" | "email" | "password" | "search" | "number" | "tel"text(default),emailorurl: the matching keyboard and autofill on phones.radiusComponentRadiusCorner radius:
none,small,medium(the design),largeorfull. The provider's default otherwise.showStrengthbooleanFour-segment meter with a word under it (create and reset only).
isRevealedbooleanControlled visibility:
trueshows 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) => voidCalled with the next visibility when the show / hide button is pressed.
shortcutstringA key hint shown at rest ("/"); the app binds the key.
showStepperbooleanThe stepper on the end, for small integers.
currencystringMoney: 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.
localestringFormats and parses in this locale instead of the provider's (the branch locale).
countrystringControlled 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): passcountryto keep Canada.defaultCountrystringThe country an empty field opens on; by default the locale's region ("de-AT" → AT, "en" → US).
suggestedCountriesreadonly string[]ISO codes shown first, above "All countries" (the markets this form expects).
onUnsupportedInternationalPaste(pasted: string) => voidA 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, thesuggestedCountries("Suggested countries"); -allCountries: the header above the rest when suggestions show ("All countries").