@hacline/ui/fieldField
A form field container built on @ui-sdk/react/field that automatically connects labels, descriptions, native validation errors, and FieldSet group disabling.
Imports
import {
Field,
FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
FieldLegend,
FieldSet,
} from "@/components/ui/hacline/components/field";Basic Usage
Field automatically wires id, for, and aria-describedby relationships between the inner control, FieldLabel, and FieldDescription. When the control has required, the label automatically displays a required indicator.
Used as the unique path for your public profile.
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/hacline/components/field";
import { Input } from "@/components/ui/hacline/components/input";
export function UsernameField() {
return (
<Field name="username">
<FieldLabel>Username</FieldLabel>
<Input autoComplete="username" placeholder="hollis" required />
<FieldDescription>
Used as the unique path for your public profile.
</FieldDescription>
</Field>
);
}Validation & Error Messages
Combine native HTML validation constraints (required, type="email", pattern) with the match prop on FieldError to display custom error messages on failed submission and clear them automatically once input becomes valid.
<form onSubmit={(event) => event.preventDefault()}>
<Field name="email">
<FieldLabel>Work email</FieldLabel>
<Input placeholder="name@company.com" required type="email" />
<FieldError match="valueMissing">Please enter your work email.</FieldError>
<FieldError match="typeMismatch">
Please enter a valid email address.
</FieldError>
</Field>
<Button type="submit">Validate & submit</Button>
</form>Field Grouping (FieldSet)
Use FieldSet, FieldLegend, and FieldGroup to organize related fields and disable them together at the group level with disabled.
<FieldSet>
<FieldLegend>Project basics</FieldLegend>
<FieldGroup>
<Field name="project">
<FieldLabel>Project name</FieldLabel>
<Input defaultValue="Hacline" required />
</Field>
<Field disabled name="region">
<FieldLabel>Deployment region</FieldLabel>
<Input defaultValue="ap-east-1 (locked)" />
</Field>
</FieldGroup>
</FieldSet>Props
Field
Prop
Type
FieldError
Prop
Type