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

Group

headerProminence

Billing address

Other controls

Label action

Several controls

Sizing

size
We'll never share your email with anyone else.

Optical alignment

optically-align="start"
We'll never share your email.

For whole forms, on the web and on a phone, see Settings Forms.

API

PropTypeDefaultDescription
labelstring—Label text for the field
hide-labelbooleanfalseHides 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 slotVNode[]—Rich label content; takes precedence over the label prop
descriptionstring—Helper text below the label; linked via aria-describedby (or the description slot)
error-messagestring—Error message below the control; sets aria-invalid on the child (or the errorMessage slot)
label-actionstring—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
requiredbooleanfalseShows 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
rowbooleanfalseOne 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
fillbooleanfalseOn a row, the control takes the rest of the line after the label
#actionslot—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
idstring—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
classstring—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

PropTypeDefaultDescription
titlestring—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)
descriptionstring—Line under the title (or the description slot)
columnsbooleanfalseEvery 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
bodyClassstring—Applied to the block that holds the rows
default slotVNode—The rows
action slotVNode—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 slotVNode—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 (default var(--color-text-danger-outline))
  • --field-error-font-size: error font size (default 0.75rem)
  • --field-error-gap: error gap (default spacing(2))
  • --field-error-icon-size: error icon size (default 1rem)
  • --field-error-line-height: error line height (default var(--font-text-xs-line-height))
  • --field-error-margin-bottom: error margin bottom (default spacing(3))
  • --field-error-margin-top: error margin top (default 0.5rem)
  • --field-error-padding-inline: error padding inline (default 0)
  • --field-horizontal-control-width: horizontal control width (default 240px)
  • --field-horizontal-control-flex: flex of the horizontal control (default 0 0 auto; 0 1 auto on a phone with touch.css, so the control narrows instead of overflowing)
  • --field-horizontal-label-width: horizontal label width (default 120px)
  • --field-label-font-weight: label font weight (default var(--font-weight-medium))
  • --field-row-above-color: colour of a label above its value (default var(--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 (default 0.8125rem)
  • --field-row-above-font-weight: weight of a label above its value (default var(--font-weight-medium))
  • --field-row-above-gap: space under a label above its value (default 4px)
  • --field-row-above-line-height: line height of a label above its value (default 1.125rem)
  • --field-row-above-padding-block: padding of a row with a label above its value (default 10px)
  • --field-row-action-font-size: text size of the action button (default var(--font-text-sm-size))
  • --field-row-action-font-weight: text weight of the action button (default var(--font-weight-medium))
  • --field-row-action-size: height of the action button (default 2rem)
  • --field-row-control-width: width of a framed number in a row (default 160px)
  • --field-row-description-font-size: description size on a row (default var(--font-text-sm-size))
  • --field-row-description-line-height: description line height on a row (default var(--font-text-sm-line-height))
  • --field-row-gap: space between label and control (default 24px, 16px on a fill row)
  • --field-row-label-font-size: label size on a row (default var(--font-text-sm-size))
  • --field-row-label-font-weight: label weight on a row (default var(--font-weight-medium))
  • --field-row-label-line-height: label line height on a row (default var(--font-text-sm-line-height))
  • --field-row-label-width: label column of a fill row (default 80px)
  • --field-row-list-label-offset: moves the label to the middle of a list's first line (default 6px)
  • --field-row-list-padding-block: padding of a fill row with an action (default 10px)
  • --field-row-list-row-gap: space above a list on its own line (default 8px)
  • --field-row-min-height: row height (default 52px)
  • --field-row-padding-block: row padding (default 10px)
  • --field-row-padding-inline: row padding (default 16px; on a phone --mobile-list-inset, 20px, where an iOS cell's text starts)
  • --field-row-row-gap: space above an error (default 2px)
  • --field-row-text-display: contents runs the description under the control (default flex)
  • --field-row-text-padding-block: row padding with a description or an error (default 10px)
  • --field-row-text-width: width of a framed text field in a row (default 240px)

FieldGroup reads these:

  • --field-group-background: block background (default transparent)
  • --field-group-border-width: block border (default 1px)
  • --field-group-description-font-size: description size (default var(--font-text-sm-size); 15px on a phone)
  • --field-group-description-line-height: description line height (default var(--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 (default 8px 0 0; 8px 20px 6px on a phone)
  • --field-group-footer-paragraph-gap: space between footer paragraphs (default spacing(2); 16px on a phone)
  • --field-group-header-min-height: header height (default spacing(8))
  • --field-group-header-padding-bottom: space under the header (default spacing(2))
  • --field-group-radius: block radius (default 1rem)
  • --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 (default var(--color-text))
  • --field-group-title-font-size: title size (default var(--font-text-md-size))
  • --field-group-title-font-weight: title weight (default var(--font-weight-medium))
  • --field-group-title-letter-spacing: title tracking (default normal)
  • --field-group-title-line-height: title line height (default var(--font-text-md-line-height))
  • --field-group-title-padding-inline: title inset (default 0; 20px on a phone)