Text
A labelled single-line or multi-line text input with auto-grow, icons, clearing, and a rolling character count.
import { TextInput } from '@uthereal/ui/text-input'Text input playground
Overview
TextInput unifies a native <input> and <textarea> inside the shared field anatomy: label, bordered control, description, error message, and optional character count. Set multiline to switch from a single-line control to a multi-line box. Your application owns the value and validation; TextInput reports every edit and never shows native browser validation bubbles.
| Capability | Single-line (multiline={false}) | Multiline (multiline={true}) |
|---|---|---|
| Native element | <input> (text, email, url, tel) | <textarea> |
| Height | Control height (36px, 44px, 50px) | Resizable box (>= 110px), or autoGrow from minRows to maxRows |
| Adornments & clear | icon, endIcon, clearable | Single-line only (rejected by schema when multiline is true) |
| Character count | showCount with optional maxLength | showCount with optional maxLength |
defaultValue max | 2,048 characters | 10,000 characters |
Enter key | Submits enclosing form | Inserts a new line |
| Leaving word motion | 180ms | 160ms |
Use TextInput for free-form text, emails, URLs, notes, and composers. Use Number for bounded numeric entry, Tags for discrete token lists, and Mention for @-triggered entity references.
Usage
'use client'
import { useState } from 'react'
import { TextInput } from '@uthereal/ui/text-input'
export function InviteEmail() {
const [email, setEmail] = useState('')
return (
<TextInput
label="Work email"
type="email"
autoComplete="email"
required
value={email}
onValueChange={setEmail}
error={
email && !email.includes('@')
? 'Enter a full email address.'
: undefined
}
/>
)
}Omit value for an uncontrolled field initialized from defaultValue. onValueChange fires in both controlled and uncontrolled modes, including when cleared; native onChange runs before onValueChange on user edits and does not fire on clear.
Examples
Multiline, auto-grow, and character count
Set multiline for notes, feedback, and composers. By default, a multiline box starts at minRows lines (at least 110px tall) with 12px inner padding and vertical resizing on pointer devices. Enable autoGrow to grow with the text from minRows to maxRows lines before scrolling; pair minRows={1} with variant="soft" for a compact composer. Add showCount (with or without maxLength) to display a rolling character count below the control; a controlled value past maxLength turns the count to --ui-danger.
Icons, clearing, and hidden labels
In single-line mode, icon and endIcon render decorative glyphs from the icon list. Set clearable to show a clear button whenever the field is editable and non-empty; clearing calls onValueChange('') and returns focus to the input. Provide a specific clearLabel when several clearable inputs share a page, and use hideLabel only when surrounding UI already names the control.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Text" | Visible label and accessible name. Name the information asked for, in sentence case. |
hideLabel | booleanDefault: false | Hide the label visually when the context already names the field. It is still announced. |
description | string— | Supporting text below the field, announced with it. Use it for format hints and constraints. |
error | string— | Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely. |
required | booleanDefault: false | Marks the field as required for assistive technology and shows an indicator. Your application validates the value. |
readOnly | booleanDefault: false | The value can be focused, selected, and copied, but not edited. It is still submitted with a form. |
disabled | booleanDefault: false | Unavailable and removed from the tab order. A disabled field is not submitted with a form. |
name | string— | Native form field name, submitted with the value in a form. |
multiline | booleanDefault: false | Render a textarea for multi-line answers such as feedback or notes. Icons, the clear button and input types other than text are single-line only. |
type | text | email | url | telDefault: "text" | Input type. email, url and tel adapt mobile keyboards and autofill; the browser does not validate them, your application does. |
placeholder | string— | Example text while the field is empty. Never a substitute for the label. |
defaultValue | stringDefault: "" | Initial text. Later argument edits do not reset an existing instance; use value and onValueChange to control it. |
maxLength | integer— | Maximum number of characters the user can type. Omit it for no limit. |
showCount | booleanDefault: false | Show the character count below the field, as "12/500" when maxLength is set. It is announced with the field. |
icon | IconName— | Decorative icon before the text (single-line), e.g. mail, phone or globe. Any name from the Icons page. |
endIcon | IconName— | Decorative icon after the text (single-line). Directional icons mirror in RTL. |
clearable | booleanDefault: false | Show a clear button while the field has a value and is editable (single-line). Clearing returns focus to the input. |
clearLabel | stringDefault: "Clear" | Accessible name of the clear button, e.g. "Clear search". |
autoGrow | booleanDefault: false | With multiline, grow with the content from minRows up to maxRows, then scroll. Off (the default, as in Arc) is a box at least 110px tall that the user resizes vertically. |
minRows | integerDefault: 3 | Visible lines when empty (multiline), from 1 to 20. |
maxRows | integerDefault: 8 | Lines shown before the content scrolls when autoGrow is on (multiline), up to 40. Values below minRows act as minRows. |
autoComplete | string— | Autofill hint such as email, name, organization or one-time-code. Use off to opt out. |
inputMode | none | text | tel | url | email | numeric | decimal | search— | Virtual keyboard on touch devices. Omit it to follow the type. |
variant | outline | soft | ghostDefault: "outline" | Field surface: outline for forms, soft on busy surfaces, ghost for inline editing without a border. |
size | sm | md | lgDefault: "md" | Field height and text size: 32, 36, or 46 pixels. Matches the button and dropdown trigger of the same size. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | TextInputTheme— | Color mode, accent, and semantic tokens. See Theming for all keys and defaults. |
motion | none | subtle | expressiveDefault: "subtle" | Hover and focus colors and the message copy: rows open their height, words rise in and the count rolls. Reduced motion keeps short fades; none makes everything immediate. |
dir | ltr | rtl— | Reading direction. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
value, onValueChange | Controlled text and change callback. onValueChange fires in both modes and when cleared. |
ref | Ref to the native <input> element, or <textarea> when multiline is true. |
id | Control element id; label, description, error, and count ids derive from it. |
preset | Application defaults (such as variant, size, and recipe), overridden by explicit props. |
tokens | CSS custom properties (--ui-*) applied after the typed theme on the field root. |
renderIcon(name, context) | Custom renderer for icon (and endIcon when renderEndIcon is omitted); context holds size, slot. |
renderEndIcon(name, context) | Custom renderer for endIcon only. Keep rendered icons decorative. |
className, style | Applied to the root field element, which carries the resolved --ui-* tokens. |
| Native attributes | Forwarded to <input> or <textarea> (onChange, onBlur, onFocus, onKeyDown, spellCheck, aria-*). |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Moves focus to the control, then to the clear button when visible. |
Enter, Space | On the clear button: clears the value and returns focus to the input. |
Enter | Submits an enclosing form in single-line mode; inserts a line in multiline. |
| Text keys | Standard browser text editing and selection shortcuts. |
The label renders as a native <label> and links through aria-labelledby, so hideLabel remains announced to assistive technology. aria-describedby joins any consumer aria-describedby with description, error, and the showCount indicator so screen readers announce constraints and counts with the field rather than interrupting typing. Setting error sets aria-invalid="true" and mounts the error with role="alert". required sets aria-required="true" without native validation bubbles.
Focus answers with a border-only edge change (ink when valid, danger when invalid) with no outer ring or layout shift. Spacing and directional icons adapt via logical CSS properties for dir="rtl", touch devices suppress the native textarea resize handle (@media (pointer: coarse)), and forced-colors: active preserves system borders, focus outlines, disabled states, and bold over-limit counts.
Motion and theming
- Border states: hover and focus transition the control border color on Arc's standard curve (
160ms). - Messages and count:
descriptionanderrorrows open their height on the smooth spring; changed words rise in through a subtle blur while unchanged words hold still (180msword exit single-line,160msmultiline). Numbers in messages andshowCountroll digit by digit on the snappy spring as columns morph width. - Auto-grow: row counts update synchronously via
useLayoutEffectandResizeObserverwithout animating height, so text never shifts under the caret. - Reduced motion:
prefers-reduced-motion: reducedisables border transitions, word travel, blur, and digit rolling, mounts message rows at full height, and keeps120msopacity fades.motion="none"makes all updates immediate (0ms).
theme accepts the core and control token groups (controlHeight, controlPaddingX, controlGap, iconSize) plus borderStrong. An optional UtherealProvider supplies application-wide defaults.
Composition
TextInput is a leaf component. Its text value is host state stored at /fields/instance-<id>/value, initialized from defaultValue and preserved across configuration edits. See Building with agents.
{
"type": "TextInput",
"props": {
"label": "Release notes",
"multiline": true,
"autoGrow": true,
"minRows": 2,
"maxLength": 500,
"showCount": true
},
"children": []
}