Field
Wires a label, control, description and error together — ids and aria attributes included. Errors slide in, never jump.
This is your public display name.
Playground
Tweak the props, the preview and the code follow.
This is your public display name.
<Field>
<FieldLabel>Username</FieldLabel>
<FieldControl>
<Input />
</FieldControl>
<FieldDescription>This is your public display name.</FieldDescription>
<FieldError>This username is already taken.</FieldError>
</Field>Installation
npx @plumsydev/plum-ui add fieldAlso pulls in label automatically.
Usage
import {
Field,
FieldControl,
FieldDescription,
FieldError,
FieldLabel,
} from "@/components/ui/field"<Field invalid={!!error}>
<FieldLabel>Email</FieldLabel>
<FieldControl>
<Input type="email" />
</FieldControl>
<FieldDescription>We’ll never share it.</FieldDescription>
<FieldError>{error}</FieldError>
</Field>Examples
Validation
Set invalid on the field and the error animates its height in. Try submitting empty.
Horizontal
Use orientation="horizontal" for settings rows.
Get a digest of activity every morning.
Product updates and launches.
API Reference
Field
The context provider. Generates ids for its parts.
| Prop | Type | Default |
|---|---|---|
invalidMarks the control as invalid and reveals FieldError. | boolean | false |
disabledDisables the control and dims the field. | boolean | false |
orientationStack or row layout. | "vertical" | "horizontal" | "vertical" |
idOverride the generated control id. | string | — |
FieldControl
A Slot that passes id, aria-describedby, aria-invalid and disabled to its child.
FieldError
Renders only when the field is invalid and it has children. Announced with role="alert".
FieldSet / FieldLegend / FieldGroup / FieldContent
Layout helpers for grouping fields.