TextField
Text and number inputs with a label, a hint or an error, prefixes, suffixes, icons and shortcut hints.
Example
<TextField label="Report name" placeholder="e.g. Weekly revenue" hint="Shown in the sidebar" />
<NumberField
label="Target"
prefix="$"
value={target}
onChange={setTarget}
error={target != null && target < 0 ? 'Target must be a positive number.' : undefined}
/>
<TextField label="Data source" defaultValue="warehouse.orders" suffix="locked" disabled />
<TextField label="Search" type="search" icon={<IconSearch />} placeholder="Metrics, charts…" />Usage
TextField spreads native input attributes. prefix is an attached segment, suffix sits inside the right edge, and shortcut shows a key hint (set focusOnShortcut to make it work).
NumberField's value is a number or null. It shows grouped digits when not focused, and ↑ / ↓ step the value (Shift for ten steps). onChange fires with every parseable value while typing, and again on blur after clamping to min and max.
Props
TextField
aria-invalid. Pass true for invalid styling without a message.focusOnShortcut.shortcut chord is pressed anywhere (⌘ also matches Ctrl).inputMode/type.Also accepts the props of Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'>, spread onto the root element.
NumberField
Also accepts every TextField prop except the value and input-type props.
Also accepts the props of Omit< TextFieldProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'min' | 'max' | 'step' | 'inputMode' >, spread onto the root element.
Accessibility
- The label is attached to the input, and the hint or error describes it.
errorsetsaria-invalid; passtruefor invalid styling without a message.