Skip to content

GhostField ​

GhostField connects a single control with its label, description, and validation message. Start with the compound parts from @ghostvue/themes for the themed stack.

Workspace profile ​

Workspace profile

Form composition with required, invalid, textarea, and disabled GhostField rows.

Workspace profile

Visible to members across shared projects and audit logs.

Enter an address like team@company.com.

The form starts with an invalid Support email. Press Enter in the field to try saving. Focus stays on the invalid control. Enter team@company.com. The error clears and the hint stays associated. Press Enter again to see the Profile saved. confirmation. The disabled organization ID stays outside the tab order.

Themed stack ​

Themed stack

Default vertical spacing from @ghostvue/themes.

Spread the GhostFieldControl slot props onto the control to give it the generated ID, state flags, and associated description.

Invalid and required ​

Use required for a native constraint and invalid for your form’s validation state. In the profile form above, the error renders only while the email is invalid. The description remains linked as the user edits the address.

Textarea ​

Use the same label, description, and control parts with GhostTextarea. The profile form uses them for Bio. See the release notes composer for a full textarea workflow.

Wrapping checkbox label ​

Wrapping checkbox

Toggle a weekly digest with a themed checkbox and its wrapping label.

Set associate="wrap" on GhostFieldLabel when the control lives inside the label. The default associate="reference" sets for to the generated control id.

Billing address

Group labelled inputs in a native fieldset and inspect the submitted address.

Billing address

Use the address on your invoice.

Include your apartment number.

Use the postal city name.

Example settings
Group a single radio question
Billing cadence

The Billing address legend names the native fieldset. Each input keeps its own label and hint. Open Example settings to disable the section or show a group or city error. Save address displays the entries from the native form. Disabling the fieldset preserves typed values and omits them from submission. An enabled control inside its first legend still participates.

For a single radio question, put one legend directly inside the radio group. Arrow keys select the value submitted under cadence.

vue
<GhostRadioGroup as="fieldset" name="cadence" default-value="annual">
  <legend>Billing cadence</legend>
  <label><GhostRadioGroupItem value="monthly" /> Monthly</label>
  <label><GhostRadioGroupItem value="annual" /> Annual</label>
</GhostRadioGroup>

Using GhostField inside GhostForm ​

Pass a canonical dot-path name prop when composing GhostField inside GhostForm so invalid state, <GhostFieldError /> text, and blur/change tracking wire automatically while standalone fields (outside GhostForm, or inside GhostForm without name) stay prop-driven. Explicit :invalid="true" or :invalid="false" on GhostField always overrides form state.

A GhostDatePickerInput inside a field also reports its own errors there, with or without a form: a rejected date marks the field invalid and shows the picker's reason in <GhostFieldError />.

Customize with headless fields ​

Import the field parts from @ghostvue/vue for your own layout or styles.

Basic labeled input ​

Labeled input Headless

Label, hint, and control id wiring for GhostInput.

Headless validation and textarea ​

Invalid field Headless

Required filter with error copy and aria-invalid.

Enter at least two characters.
Textarea field Headless

GhostTextarea composed with description.

Headless address fieldset ​

For headless styling, keep the fieldset and legend and import the field parts from @ghostvue/vue. A plain labelled native input can also receive the field control slot props.

Headless address fieldset Headless

The same native fieldset recipe with headless GhostField parts and consumer-owned styles.

Shipping address

Deliveries go to this address.

Styling hooks ​

Parts expose data-part="label" | "description" | "error" | "control". Themed CSS stacks children with spacing tokens under .ghost-theme or .ghost-themed-scope.

Composable ​

useGhostField returns SSR-stable ids and state for custom layouts that still use the field relationship contract.

API ​

GhostField ​

PropTypeDefaultDescription
disabledbooleanfalsePropagates disabled semantics to the control.
idstring—Optional control id override for label association.
invalidboolean—Propagates invalid semantics and root data-state.
namestring—Canonical dot-path key associating this field with an ancestor GhostForm.
requiredbooleanfalsePropagates required semantics to the control.
SlotSlot propsDescription
defaultdirty: boolean, error: string | undefined, errors: readonly string[], invalid: boolean, touched: booleanField parts (label, description, control, error) in consumer-chosen order.

@ghostvue/themes adds no props, events, or slots to the headless GhostField API, which it forwards.

Root: class ghost-field, data-ghost-field, data-part="root", optional data-state="invalid" | "disabled".

GhostFieldLabel ​

PropTypeDefaultDescription
asGhostFieldLabelElement"label"Label element.
associateGhostFieldLabelAssociate"reference"for association or nested labeling.
requiredbooleanfalseShows the required marker with root required.
showRequiredbooleantrueToggles the visual required indicator.
SlotSlot propsDescription
default—Primary content.

GhostFieldDescription ​

Default element p with stable id for aria-describedby.

GhostFieldError ​

Default element span with role="alert" when the slot has content.

GhostFieldControl ​

Scoped slot props:

NameTypeDescription
idstringShared control id.
disabledbooleanFrom root.
invalidbooleanFrom root.
requiredbooleanFrom root.
aria-describedbystringDescription and error ids when mounted.
aria-invalidbooleanPresent when root invalid is true.

Accessibility ​

  • Name the control with GhostFieldLabel (for or wrap).
  • Hints and errors are linked with aria-describedby.
  • Invalid uses native aria-invalid / invalid on library controls.
  • Field does not trap focus or handle keyboard input; the control does.