Field
Form field wrapper with a label, helper text, an error message, and automatic accessibility linking to its control.
import { Field } from "@plexui/vue/components/Field";
import { FieldGroup } from "@plexui/vue/components/FieldGroup";Examples
Overview
layout
Enter a valid email address.
Group
headerProminence
Billing address
Other controls
Editor
Select date
Label action
Several controls
Month
Day
Year
Sizing
size
We'll never share your email with anyone else.
Enter a valid email address.
Optical alignment
optically-align="start"
We'll never share your email.
Enter a valid email address.
For whole forms, on the web and on a phone, see Settings Forms.
API
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Label text for the field |
hide-label | boolean | false | Hides the label from view; it still names the control. A description moves under the control. On a row the value or placeholder starts at the row's edge, so the row is vertical unless orientation says otherwise |
label slot | VNode[] | — | Rich label content; takes precedence over the label prop |
description | string | — | Helper text below the label; linked via aria-describedby (or the description slot) |
error-message | string | — | Error message below the control; sets aria-invalid on the child (or the errorMessage slot) |
label-action | string | — | Content at the end of the label row, such as a link that acts on the field (or the labelAction slot) |
size | "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | child's size, else "md" | Label font size; defaults to the child control's size |
required | boolean | false | Shows a required asterisk after the label (visual only) |
orientation | "vertical" | "horizontal" | "horizontal" on a row with a visible label, else "vertical" | Layout direction of label and control |
row | boolean | false | One line of a FieldGroup. Clicking its non-interactive area focuses the text editor or activates the choice or popup control. Other attributes reach the root only on a row |
fill | boolean | false | On a row, the control takes the rest of the line after the label |
#action | slot | — | On a fill row, a control at the end of the row, such as a button that adds to a list. It stays on the list's first line, and on a phone it stands beside the label with the list under it |
optically-align | "start" | "end" | — | Applies optical alignment to the child control via negative margin using its gutter |
id | string | — | Override the generated id used for the label's for and aria linking. A child's own id wins: it stays, and the label's for follows it |
class | string | — | CSS classes applied to the root element |
default slot | (fieldProps) => VNode[] | — | Form control; its single root element receives id, aria-describedby and aria-invalid (plus aria-labelledby unless it has its own name) unless the slot reads fieldProps, which include aria-labelledby |
FieldGroup
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | Heading over the block (or the title slot); it names the group |
header-prominence | "standard" | "increased" | "standard" | How much the title stands out: a quiet heading over the rows, or a title that leads its content (on a phone the iOS prominent list header, 20pt Semibold) |
description | string | — | Line under the title (or the description slot) |
columns | boolean | false | Every value starts at one column, --field-row-column-width into the row, on the web and on a phone. Off, values end at the row's edge |
bodyClass | string | — | Applied to the block that holds the rows |
default slot | VNode | — | The rows |
action slot | VNode | — | Content at the end of the header. On a phone a ghost text button reads as the list header's action: tinted text on the title's last line |
footer slot | VNode | — | Content under the block, such as a note; its paragraphs stand apart |
Styling
Field reads these component tokens. Override them at any scope to restyle it:
--field-error-color: error color (defaultvar(--color-text-danger-outline))--field-error-font-size: error font size (default0.75rem)--field-error-gap: error gap (defaultspacing(2))--field-error-icon-size: error icon size (default1rem)--field-error-line-height: error line height (defaultvar(--font-text-xs-line-height))--field-error-margin-bottom: error margin bottom (defaultspacing(3))--field-error-margin-top: error margin top (default0.5rem)--field-error-padding-inline: error padding inline (default0)--field-horizontal-control-width: horizontal control width (default240px)--field-horizontal-control-flex: flex of the horizontal control (default0 0 auto;0 1 autoon a phone withtouch.css, so the control narrows instead of overflowing)--field-horizontal-label-width: horizontal label width (default120px)--field-label-font-weight: label font weight (defaultvar(--font-weight-medium))--field-row-above-color: colour of a label above its value (defaultvar(--color-text-tertiary))--field-row-popup-value-color: colour of the value of a Select at the end of a row on a phone (default the secondary label, as the pop-ups of Reminders and Calendar;var(--color-text)gives the primary label of the Files View Options sheet)--field-row-above-font-size: size of a label above its value (default0.8125rem)--field-row-above-font-weight: weight of a label above its value (defaultvar(--font-weight-medium))--field-row-above-gap: space under a label above its value (default4px)--field-row-above-line-height: line height of a label above its value (default1.125rem)--field-row-above-padding-block: padding of a row with a label above its value (default10px)--field-row-action-font-size: text size of the action button (defaultvar(--font-text-sm-size))--field-row-action-font-weight: text weight of the action button (defaultvar(--font-weight-medium))--field-row-action-size: height of the action button (default2rem)--field-row-control-width: width of a framed number in a row (default160px)--field-row-description-font-size: description size on a row (defaultvar(--font-text-sm-size))--field-row-description-line-height: description line height on a row (defaultvar(--font-text-sm-line-height))--field-row-gap: space between label and control (default24px,16pxon afillrow)--field-row-label-font-size: label size on a row (defaultvar(--font-text-sm-size))--field-row-label-font-weight: label weight on a row (defaultvar(--font-weight-medium))--field-row-label-line-height: label line height on a row (defaultvar(--font-text-sm-line-height))--field-row-label-width: label column of afillrow (default80px)--field-row-list-label-offset: moves the label to the middle of a list's first line (default6px)--field-row-list-padding-block: padding of afillrow with anaction(default10px)--field-row-list-row-gap: space above a list on its own line (default8px)--field-row-min-height: row height (default52px)--field-row-padding-block: row padding (default10px)--field-row-padding-inline: row padding (default16px; on a phone--mobile-list-inset, 20px, where an iOS cell's text starts)--field-row-row-gap: space above an error (default2px)--field-row-text-display:contentsruns the description under the control (defaultflex)--field-row-text-padding-block: row padding with a description or an error (default10px)--field-row-text-width: width of a framed text field in a row (default240px)
FieldGroup reads these:
--field-group-background: block background (defaulttransparent)--field-group-border-width: block border (default1px)--field-group-description-font-size: description size (defaultvar(--font-text-sm-size); 15px on a phone)--field-group-description-line-height: description line height (defaultvar(--font-text-sm-line-height); 20px on a phone)--field-group-footer-font-size: footer size (default the description size; 13px on a phone)--field-group-footer-line-height: footer line height (default the description line height; 16px on a phone)--field-group-footer-padding: footer padding (default8px 0 0;8px 20px 6pxon a phone)--field-group-footer-paragraph-gap: space between footer paragraphs (defaultspacing(2); 16px on a phone)--field-group-header-min-height: header height (defaultspacing(8))--field-group-header-padding-bottom: space under the header (defaultspacing(2))--field-group-radius: block radius (default1rem)--field-group-separator-inset: on a phone, how far the line between rows stands from both ends of the row (--mobile-list-inset, 20px, where the row's text starts)--field-group-separator-inset-start: where the line starts (default--field-group-separator-inset). Set it on a row that leads with an icon to start the line after the icon, where its text starts, or on the group for every row--field-group-separator-inset-end: where the line ends (default--field-group-separator-inset)--field-group-title-color: title color (defaultvar(--color-text))--field-group-title-font-size: title size (defaultvar(--font-text-md-size))--field-group-title-font-weight: title weight (defaultvar(--font-weight-medium))--field-group-title-letter-spacing: title tracking (defaultnormal)--field-group-title-line-height: title line height (defaultvar(--font-text-md-line-height))--field-group-title-padding-inline: title inset (default0; 20px on a phone)