Field wraps a control with a label and a hint or error. Input, Select, Textarea, InputSelect and InputButton are the controls.
Default
A label, a text input and a hint below it.
Clients see this name on proposals and invoices.
Installation
Copies the component into src/design-system/ as your own source, with only the files it needs.
npx avesk-ui@latest add fieldBrings the 4 files it builds on (icon.tsx, select-menu.tsx, floating.tsx, glyph.tsx). The first time, it also adds the tokens and the cn() helper, imports the tokens in globals.css and installs clsx and tailwind-merge. Files already in your project are kept unless you add --force.
Import
Lives in src/design-system/components/field.tsx.
import { frame, controlStates, Field, fieldDescribedBy, Input, InputButton, InputSelect, Select, Textarea } from "@/design-system/components/field";Usage
<Field id="site-url" label="Web address" required error={error}>
<Input
id="site-url"
leadingText="https://"
aria-invalid={error ? true : undefined}
aria-describedby={fieldDescribedBy("site-url", error)}
/>
</Field>Examples
Icons and add-ons
Leading icon, fixed text, a currency dropdown and a joined button.
Select
Pick one option. Takes <option> children like a native select, but the list opens in the system menu style, with a tick on the current choice.
Moves the project on the board.
Textarea
Multi-line text for briefs, notes and feedback.
Error and disabled
An error message replaces the hint; disabled fields keep their value but can't be edited.
Enter a valid email, like maya@denzing.com.
Set automatically.
When to use
Use it when
- Every single-line text, number, email, URL or search input
- A dropdown of fewer than ~15 options (Select)
- Multi-line text (Textarea)
Don’t use it when
- Picking a date → Date picker
- Yes/no that applies immediately → Switch
- 2–5 visible choices → Radio or Choice chip
- Uploading a file → File upload
Rules
- Always wrap a control in Field so it has a visible label
- Mark errors with aria-invalid on the control and error on Field; link with fieldDescribedBy()
- Optional fields say "(optional)"; required ones say nothing
- Inputs are 40px tall
- Select's list opens below, or above when there's no room, in the top layer so a scrolling panel or dialog can't crop it
Properties
Field
| Prop | Type | Default |
|---|---|---|
id * | string | – |
label * | string | – |
required | boolean | – |
hint | string | – |
error | string | – |
children * | ReactNode | – |
Input
| Prop | Type | Default |
|---|---|---|
leadingIcon | IconName | – |
leadingGraphic | ReactNode | – |
leadingText | string | – |
leadingSelect | ReactNode | – |
prefix | string | – |
trailingSelect | ReactNode | – |
trailingButton | ReactNode | – |
help | string | – |
* required
Accessibility
- Label is tied by id/htmlFor
- Hint and error are announced through aria-describedby
- help text on Input becomes the help icon's accessible name
Related
Used in the Avesk app: Finance & Growth, Design Inspiration, Projects & Clients, Onboarding, App shell.