Input
A single-line text field for short free-form data such as names, numbers, e-mails and search terms, with optional label, hint and icons.
Formato NNNNNNN-DD.AAAA.J.TR.OOOO
<Input hint="Formato NNNNNNN-DD.AAAA.J.TR.OOOO" label="Número do processo" placeholder="0001234-56.2024.5.02.0001" size="sm" type="text" variant="default" />SearchInput and CurrencyInput are exported from the same module and are
documented below.
When to use
- To collect one line of free text: process number, client name, e-mail.
- To collect formatted values with the right native
type: password, number, URL. - To filter a list or table with
SearchInput. - To collect an amount in reais with
CurrencyInput.
When not to use
- Several lines of text. Use Textarea.
- A date. Use Date input, which masks the digits and validates the date.
- A list of values, such as many process numbers. Use Textarea chips.
- A one-time code. Use Input OTP.
- Choosing from a fixed list. Use Select, Radio group or Combobox.
Variants
variant sets the validation state. When no variant is passed, the field is
default.
Número encontrado na base.
Número incompleto. Use o formato NNNNNNN-DD.AAAA.J.TR.OOOO.
Processo localizado.
Definido pelo modelo de tarefa.
| Variant | Use for |
|---|---|
default |
A field with no validation result yet. |
error |
An invalid value. Sets aria-invalid and colors the hint. |
success |
A value confirmed by the system, such as a process found in the base. |
blocked |
A value the user cannot change. Disables the field and drops focus. |
ghost |
A field with no border, for inline editing inside tables and headers. |
Sizes
sm is the default and fits most forms. Use md and lg where hit targets
must be larger.
| Size | Height | Use for |
|---|---|---|
lg |
56px | Prominent forms and sign-in pages. |
md |
48px | Touch devices. |
sm |
40px | Default. Forms and dialogs. |
xsm |
36px | Compact layouts and filters. |
xxs |
32px | Dense tables and toolbars. |
States
- Hover darkens the fill and focus swaps the border to
--stroke-focus. Both come from the browser, so point at a field or press Tab to see them. - Read-only keeps the field focusable and selectable but not editable.
- Disabled removes the field from the tab order. Prefer
blockedwhen the value must stay visible and the reason is known. - Highlight draws an accent border to call attention to a field, for example a required field that was skipped.
Label and hint
Pass label and hint and the field renders the full layout: label row, field,
hint. The label is linked to the input and the hint is referenced by
aria-describedby.
Use o e-mail corporativo cadastrado no cliente.
Icons
Use iconLeading for the kind of data and iconTrailing for status. Both are
sized to 16px and hidden from assistive technology, so never rely on them alone.
Types
Search
SearchInput adds a search icon and, once there is text, a clear button.
Escape clears the text.
With collapsible, the field is an icon button until it is opened, which saves
room in toolbars.
Currency
CurrencyInput masks the digits as reais. Its onChange receives only the
digits, in cents, so "1500000" means 15.000,00.
O segundo campo começa com 1500000 centavos, exibido como 15.000,00.
Content
- Label with the noun, in sentence case: “Número do processo”, “Nome do cliente”.
- Use the placeholder for an example, never for the label: “0001234-56.2024.5.02.0001”.
- Write the hint as the rule or the fix: “Use o formato NNNNNNN-DD.AAAA.J.TR.OOOO.”
- Without
label, give the input anaria-label.
Do and don’t
Use o formato NNNNNNN-DD.AAAA.J.TR.OOOO.
Número incompleto. Use o formato NNNNNNN-DD.AAAA.J.TR.OOOO.
Accessibility
- It renders a native
<input>, so browser autofill, spell checking and the right on-screen keyboard work with the nativetype. - With
label, a<label htmlFor>is linked to the input through a generated id. Without it, passaria-label: a field with no name fails WCAG AA. variant="error"setsaria-invalidandhintis referenced byaria-describedby. Say the error in text: color alone is not enough.- Icons are
aria-hidden. A status icon needs matching text in the hint. - Focus changes the border to the focus token. The native outline is removed.
- Hit targets run from 32px (
xxs) to 56px (lg), above the 24px minimum. SearchInputnames its buttons “Abrir pesquisa” and “Limpar pesquisa”. The text is fixed in the component.
Code
import { CurrencyInput, Input, SearchInput } from "@repo/ui/input";
<Input
hint="Use o formato NNNNNNN-DD.AAAA.J.TR.OOOO."
label="Número do processo"
placeholder="0001234-56.2024.5.02.0001"
/>
// Icons
<Input aria-label="E-mail" iconLeading={<Mail />} type="email" />
// Search
<SearchInput onChange={(e) => setQuery(e.target.value)} value={query} />
// Currency: onChange receives digits in cents
<CurrencyInput
aria-label="Valor da causa"
onChange={(e) => setAmount(e.target.value)}
value={amount}
/>
Props
Input| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disables the field. Disabled fields cannot be focused |
highlight | boolean | false | Draws a highlight border to call attention to the field |
hint | string | — | Helper or error text below the field. Its color follows `variant`, and the input references it with `aria-describedby` |
iconLeading | ReactNode | — | Icon on the leading side, sized to 16px. Pass a Lucide element |
iconTrailing | ReactNode | — | Icon on the trailing side, sized to 16px. Its color follows `variant` |
label | string | — | Label above the field, linked to the input. Without `label` and `hint` the bare field renders |
left | ReactNode | — | Custom node on the leading side. Wins over `iconLeading` |
placeholder | string | — | Text shown while the field is empty |
right | ReactNode | — | Custom node on the trailing side. Wins over `iconTrailing` |
size | "lg" | "md" | "sm" | "xsm" | "xxs" | sm | Height, padding and type size |
trailingText | string | — | Secondary text at the end of the label row, such as a counter. Only shown with `label` |
type | "text" | "email" | "password" | "number" | "tel" | "url" | text | Native input type |
variant | "blocked" | "default" | "error" | "ghost" | "success" | default | Validation state. `error` also sets `aria-invalid`; `blocked` disables the field |
SearchInput (also takes the Input props, except label, hint and trailingText)| Prop | Type | Default | Description |
|---|---|---|---|
collapsible | boolean | false | Shows an icon button that expands into the field, and collapses on blur when empty. |
expandedWidth | string | "280px" | Width of the field when `collapsible` is open. |
onClear | () => void | — | Called when the user clears the text. Without it, `onChange` receives an empty value. |
placeholder | string | "Pesquisar…" | Text shown while the field is empty. |
value, onChange | string, (event) => void | — | Controlled text. The clear button shows when `value` is not empty. |
CurrencyInput (also takes the Input props)| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Amount in cents as digits, for example `"1500000"`. |
onChange | (event) => void | — | Called with `event.target.value` set to the digits only, in cents. |
Known issues
| Issue | Effect |
|---|---|
Hover uses hover:bg-neutral-black/5 and disabled uses disabled:opacity-50. |
Translucent fills, which the repository avoids. The disabled value loses contrast and may fail WCAG AA. |
The hint is a raw <p> with text-xs, and the label is a raw <label>. |
They do not follow the Typography scale tokens. |
SearchInput hardcodes “Pesquisar…”, “Abrir pesquisa” and “Limpar pesquisa”. |
Apps cannot translate these. Only the placeholder can be overridden. |
SearchInput uses text-muted-foreground for the collapsible icon. |
A token from the old color system, unlike the text-tertiary used when it is not collapsible. |
CurrencyInput formats an empty value as “0,00”. |
The placeholder never shows, and an empty field looks like the value zero. There is no “R$” prefix. |