Skip to main content

Starwind UI v3.0 beta is now available! Read the migration guide

This name appears on your public profile.

Runtime example adjustment

Field now coordinates native constraint validation and Runtime-backed controls. Match messages to validity states instead of writing page-local validation listeners.

Installation

Framework Availability

Astro Available React Available

Field is available for Astro and React.

Usage

Groups and non-input controls

Preferences

Receive occasional release notes.

API Reference

Styled Component API

These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Follow the Primitive and Runtime links for lower-level behavior props.

Field

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
errorVisibility import("@starwind-ui/runtime/form").FormValidationTiming
Description
Overrides when errors become visible for controls coordinated by this Field.
Classification
Wrapper prop
orientation "horizontal" | "responsive" | "vertical" "vertical"
Description
Selects the horizontal or vertical layout direction.
Classification
Styled variant
revalidationTiming import("@starwind-ui/runtime/form").FormValidationTiming
Description
Selects when a previously validated field is validated again.
Classification
Wrapper prop
validationTiming import("@starwind-ui/runtime/form").FormValidationTiming
Description
Selects when validation first runs.
Classification
Wrapper prop

Field Legend

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
variant "label" | "legend" "legend"
Description
Selects the component's visual variant.
Classification
Styled variant

Field Group

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
variant "default" | "outline" "default"
Description
Selects the component's visual variant.
Classification
Styled variant

Field Label

Inherits label attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Field Control

Inherits input attributes. Omits `children`, `defaultValue`, `size`, and `value`.

Contains the following additional props:

Prop Type Default Toggle details
defaultValue string | number | string[]
Description
Sets the initial value when the component is uncontrolled.
Classification
Wrapper prop
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant
value string | number | string[]
Description
Controls or identifies the component value.
Classification
Wrapper prop

Field Error

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
match boolean | "badInput" | "customError" | "patternMismatch" | "rangeOverflow" | "rangeUnderflow" | "stepMismatch" | "tooLong" | "tooShort" | "typeMismatch" | "valid" | "valueMissing"
Description
Selects the validation state that renders this message.
Classification
Primitive override
Primitive prop
field.Error.match

Field Validity

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
match boolean | "badInput" | "customError" | "patternMismatch" | "rangeOverflow" | "rangeUnderflow" | "stepMismatch" | "tooLong" | "tooShort" | "typeMismatch" | "valid" | "valueMissing"
Description
Selects the validation state that renders this message.
Classification
Wrapper prop

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Field.

Runtime API

Field primitive
createField from @starwind-ui/runtime/field
Fieldset primitive
createFieldset from @starwind-ui/runtime/fieldset

Changelog

v1.0.0

  • Added the Runtime-backed Field family with validation, grouping, labels, descriptions, and accessible messages.
  • See the Field Primitive and Fieldset Primitive for the underlying unstyled anatomy and behavior API.