TextField and TextArea
import { TextField, TextArea } from "@study/ui"
A field with a label above it, optionally a hint below it and an error when something does not fit.
Result
Loading...
Live Editor
function Example() { const [title, setTitle] = useState(""); return ( <div className="ui-stack" style={{ maxWidth: 420 }}> <TextField label="Deadline title" placeholder="e.g. Submit exercise sheet 5" value={title} onChange={(e) => setTitle(e.target.value)} error={title.length > 60 ? "At most 60 characters." : undefined} hint="Shown like this in the calendar and on Today." /> <TextArea label="Note" placeholder="What you want to remember …" /> </div> ); }
Variants and states
Light
MB
At least 10 characters.
Dark
MB
At least 10 characters.
When to use
✓ DoThe label says what goes in; the placeholder shows an example.
✗ Don'tOnly a placeholder as a label – it disappears while typing.
hideLabelonly when the purpose is clear from the surroundings (e.g. the "Add task" row in a list).- Show errors only once someone has left the field or submitted – not on the first key press.
- For searches SearchField, for choosing from a list Select.
TextAreagrows with its content up to half the window height.
Props
Plus all attributes of an <input> or <textarea>.
| Prop | Type | Default | Meaning |
|---|---|---|---|
label * | ReactNode | – | What belongs in the field. Always given; `hideLabel` hides it from the eye only. |
error | ReactNode | – | What is wrong with the value; marks the field invalid. |
hideLabel | boolean | – | |
hint | ReactNode | – | A short help below the field. |
icon | enum | – | An icon at the start of the field. |
ref | Ref<HTMLInputElement> | – | |
size | "md" | "lg" | md | |
trailing | ReactNode | – | Something at the end inside the field, e.g. a unit or an `IconButton`. |
| Prop | Type | Default | Meaning |
|---|---|---|---|
label * | ReactNode | – | What belongs in the field. Always given; `hideLabel` hides it from the eye only. |
error | ReactNode | – | What is wrong with the value; marks the field invalid. |
hideLabel | boolean | – | |
hint | ReactNode | – | A short help below the field. |
ref | Ref<HTMLTextAreaElement> | – |
Accessibility
- Label, hint and error are connected to the field through
for,aria-describedbyandaria-invalid. - Text in fields is 16 px – so the iPhone does not zoom.
- Errors are there as text, not only as a red border.