suiss/ui · Component
Field
Building blocks for form fields that pair controls with labels, descriptions and error messages.
Field is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
A Field wraps one control together with its FieldLabel, an optional FieldDescription and an optional FieldError. It automatically adds the ids of its descriptions and errors to the control's aria-describedby, so supporting text is announced with the control. Use FieldContent to stack a label and description beside a control in a horizontal field, and FieldTitle for a non-label heading inside a field.
FieldGroup stacks fields with consistent spacing, and its inset variant groups them into a rounded list, like iOS Settings. FieldSet and FieldLegend group related fields under a caption, and FieldSeparator divides sections, optionally with text. Use these parts with any control in the library, such as Input, Textarea, Checkbox, Switch or RadioGroup.
Installation
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies and add the
cnhelper:
- Update the import paths to match your project.
Usage
Connect each FieldLabel to its control with htmlFor and id. Set orientation="horizontal" to place the label beside the control, for example for a checkbox or switch, or responsive to switch from vertical to horizontal when the surrounding FieldGroup is wide enough.
To show an error, set aria-invalid on the control and render a FieldError with children or an errors array. Pass data-disabled on a Field to dim its label when the control is disabled.
To build selectable cards, place a horizontal Field inside a FieldLabel; the label gets a border, and a highlighted ring when the control inside it is checked.
Examples
With help link
A description that contains a link, styled with text-primary and an underline.
Inset
Horizontal fields in an inset field group, forming a rounded settings list with separators.
With textarea
A field that labels and describes a Textarea.
Invalid
An invalid field with an error message announced as an alert.
Multiple errors
A FieldError that renders an errors array as a bulleted list.
Disabled
A disabled field with a dimmed label and a disabled input.
Horizontal
Horizontal fields with a checkbox and a switch, one with a description in FieldContent.
Choice cards
Radio options presented as selectable cards by nesting a Field inside a FieldLabel.
Form
A complete payment form built from field sets, groups, a separator and actions.
Separator with text
A FieldSeparator with text between a sign-in button and an email field.
API Reference
FieldSet
Groups related fields in a native fieldset.
Also accepts the props of React.ComponentProps<"fieldset">.
FieldLegend
The caption of a field set.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "legend" | "label" | "legend" | Sets data-variant to legend or label so the legend can be styled as a section caption or as a field label. |
Also accepts the props of React.ComponentProps<"legend">.
FieldGroup
Stacks fields with consistent spacing, or groups them into an inset list.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "inset" | "default" | inset groups the fields into a rounded list on bg-muted, with separators between rows and inputs aligned to the end. |
Also accepts the props of React.ComponentProps<"div">.
Field
Wraps a single control with its label, description and error.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "vertical" | "horizontal" | "responsive" | "vertical" | vertical stacks the label above the control, horizontal places them side by side, and responsive switches to horizontal when the field group is wide enough. |
Also accepts the props of React.ComponentProps<"div">.
FieldContent
Stacks a label and description next to a control in a horizontal field.
Also accepts the props of React.ComponentProps<"div">.
FieldLabel
The label of a field's control.
Also accepts the props of React.ComponentProps<typeof Label>.
FieldTitle
A heading inside a field that is not a label, such as the title of a choice card.
Also accepts the props of React.ComponentProps<"div">.
FieldDescription
Supporting text that describes the control.
Also accepts the props of React.ComponentProps<"p">.
FieldSeparator
A divider between sections, with optional centered text.
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Optional text centered on the separator line. |
Also accepts the props of React.ComponentProps<"div">.
FieldError
An error message for the field.
| Prop | Type | Default | Description |
|---|---|---|---|
errors | Array<{ message?: string } | undefined> | - | A list of error objects to display. Duplicate messages are removed; one message renders as text and several render as a list. Ignored when children are provided. |
Also accepts the props of React.ComponentProps<"div">.
Accessibility
Fieldhas thegrouprole and links its descriptions and errors to its first control througharia-describedby, updating the link when they change.FieldSetrenders a nativefieldset, which takes its accessible name fromFieldLegend.FieldErrorhas thealertrole, so assistive technology announces it when it appears. It renders nothing when it has no children and no errors.- Set
aria-invalidon the control to mark it invalid;FieldErrordoes not set it for you. - Clicking a
FieldLabelfocuses or toggles its associated control.
Notes
- Styling hooks:
data-slotvaluesfield-set,field-legend,field-group,field,field-content,field-label(used by bothFieldLabelandFieldTitle),field-description,field-separatorandfield-error. Fieldsetsdata-orientation, andFieldGroupandFieldLegendsetdata-variant.FieldGroupis a container query context namedfield-group, which drives theresponsiveorientation.- Uses the
muted,border,muted-foreground,primary,destructiveandaccentcolors.

Field wraps one control, such as an Input, Textarea or Switch, with a FieldLabel, an optional FieldDescription and a FieldError. It shares the field's disabled and invalid state with the control and handles validation: required values, length limits and custom validate functions, checked on submit, blur or change.
FieldSet and FieldLegend group related fields under a heading, and FieldGroup stacks fields. The inset variant of FieldGroup turns the fields into rows on a rounded bg-muted surface with hairlines between them, like a settings list.
Installation
The CLI also adds what it builds on: Separator.
Manual
- Install the dependencies:
-
Add the pieces it builds on: Separator, and the primitives
components/primitives/field.tsx,components/primitives/fieldset.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/field.tsx:
- Update the import paths to match your project.
- Install the dependencies:
-
Add the pieces it builds on: Separator, and the primitives
components/primitives/field.tsx,components/primitives/fieldset.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/field.tsx:
- Update the import paths to match your project.
-
Add the pieces it builds on: Separator, and the primitives
components/primitives/field.tsx,components/primitives/fieldset.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/field.tsx:
- Update the import paths to match your project.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Set
minSdkto 24 or higher and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Put a FieldLabel, the control and a FieldError inside Field. The control is labelled by the label and uses the description and error text as its accessibility hint. Set invalid to force the error state, or let validation decide it.
FieldError shows its children, or the messages from errors (for example from a form library), and can be limited to one failure with match, such as tooShort. Use orientation="horizontal" for a label beside a switch or checkbox, with FieldContent holding a FieldTitle and FieldDescription.
FieldSeparator divides fields and can show short text such as "or" in the middle.
Examples
Invalid
A field in the invalid state with an error message.

Validation
Required, custom and minimum-length validation on blur and on change.

Disabled
A disabled field.

Horizontal
Switch rows with a title and description beside the control.

Checkbox group
A fieldset of checkboxes with a legend.

Inset
An inset group of rows on a rounded surface.

Form
A complete form with validation and a submit button.

API Reference
FieldSet
Group of related fields.
Also accepts the props of React.ComponentProps<typeof FieldsetPrimitive.Root>.
FieldLegend
Heading for a fieldset.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "legend" | "label" | "legend" | legend (heading) or label. |
Also accepts the props of React.ComponentProps<typeof FieldsetPrimitive.Legend>.
FieldGroup
Stack of fields, plain or inset.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | FieldGroupVariant | "default" | default or inset. |
Also accepts the props of React.ComponentProps<typeof View>.
Field
One field that shares state with its control.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | FieldOrientation | "vertical" | vertical, horizontal or responsive. |
Also accepts the props of React.ComponentProps<typeof FieldPrimitive.Root>.
FieldContent
Column for a title and description beside a control.
Also accepts the props of React.ComponentProps<typeof View>.
FieldLabel
Label linked to the control.
Also accepts the props of React.ComponentProps<typeof FieldPrimitive.Label>.
FieldTitle
Bold text for a field's title.
Also accepts the props of React.ComponentProps<typeof RNText>.
FieldDescription
Helper text.
Also accepts the props of React.ComponentProps<typeof FieldPrimitive.Description>.
FieldSeparator
Divider with optional centered text.
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - |
Also accepts the props of React.ComponentProps<typeof View>.
FieldError
Error message shown when validation fails.
| Prop | Type | Default | Description |
|---|---|---|---|
errors | Array<{ message?: string } | undefined> | - | Array of { message } objects to show. |
Also accepts the props of React.ComponentProps<typeof FieldPrimitive.Error>.
Accessibility
- The control is labelled by
FieldLabeland gets the description and error text as its accessibility hint. FieldErrorhas thealertrole, so screen readers announce it when it appears.FieldSethas thegrouprole labelled by its legend; the legend has theheaderrole.- Disabled state is passed to the label and control.
Notes
- Uses
text-foreground,text-muted-foreground,text-destructiveandbg-mutedtokens; light and dark follow the system appearance. - Inset separators use start and end offsets, so they flip in right-to-left layouts.







