Form
---import { Button } from "@/components/starwind/button";import { Field, FieldControl, FieldError, FieldLabel } from "@/components/starwind/field";import { Form, FormErrorSummary } from "@/components/starwind/form";---
<Form validationTiming="onBlur" revalidationTiming="onInput"> <FormErrorSummary aria-label="Profile errors">Review the highlighted fields.</FormErrorSummary> <Field name="email"> <FieldLabel>Email</FieldLabel> <FieldControl type="email" required /> <FieldError match="valueMissing">Enter your email address.</FieldError> <FieldError match="typeMismatch">Enter a valid email address.</FieldError> </Field> <Button type="submit">Save profile</Button></Form>import { Button } from "@/components/starwind/button";import { Field, FieldControl, FieldError, FieldLabel } from "@/components/starwind/field";import { Form, FormErrorSummary } from "@/components/starwind/form";
export function Example() { return ( <Form validationTiming="onBlur" revalidationTiming="onInput"> <FormErrorSummary aria-label="Profile errors">Review the highlighted fields.</FormErrorSummary> <Field name="email"> <FieldLabel>Email</FieldLabel> <FieldControl type="email" required /> <FieldError match="valueMissing">Enter your email address.</FieldError> <FieldError match="typeMismatch">Enter a valid email address.</FieldError> </Field> <Button type="submit">Save profile</Button> </Form> );}Runtime example adjustment
Form remains a native HTML form. The Runtime adds validation timing, field coordination, and an accessible error summary without requiring React or a form-state library.
Installation
pnpx starwind@latest add formnpx starwind@latest add formyarn dlx starwind@latest add formFramework Availability
Astro Available React AvailableForm is available for Astro and React.
Usage
The browser still owns submission and FormData. Use ordinary action, method, submit, and reset behavior; Runtime controls serialize through their installed hidden inputs.
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.
Form
Inherits form attributes.
Contains the following additional props:
errorVisibility import("@starwind-ui/runtime/form").FormValidationTiming —
- Description
- Selects when validation errors become visible.
- Classification
- Primitive override
- Primitive prop
- form.Root.errorVisibility
revalidationTiming import("@starwind-ui/runtime/form").FormValidationTiming —
- Description
- Selects when a previously validated field is validated again.
- Classification
- Primitive override
- Primitive prop
- form.Root.revalidationTiming
validationTiming import("@starwind-ui/runtime/form").FormValidationTiming —
- Description
- Selects when validation first runs.
- Classification
- Primitive override
- Primitive prop
- form.Root.validationTiming
Primitive And Runtime API
Use these references when you need the lower-level behavior APIs behind Form.
Primitive API
Runtime API
- Form primitive
createFormfrom@starwind-ui/runtime/form
Changelog
v1.0.0
- Added Runtime-backed native form coordination and validation timing.
- See the Form Primitive for the underlying unstyled anatomy and behavior API.