Form
Installation
Section titled “Installation”Copy editable source into an initialized application:
pnpm dlx @simurgh-ui/cli add formFor package consumption, import from the component subpath and load its optional recipe CSS:
import { Form, FormErrorSummary,} from '@simurgh-ui/react/form';import '@simurgh-ui/styles/form.css';import { Form, FormErrorSummary,} from '@simurgh-ui/vue/form';import '@simurgh-ui/styles/form.css';Angular
Section titled “Angular”import { FormDirective, FormErrorSummaryComponent,} from '@simurgh-ui/angular/form';import '@simurgh-ui/styles/form.css';Omit the component stylesheet for fully headless styling. CLI-copied components use the local path
written to simurgh.json and the copied application styles instead of these package imports.
Purpose
Section titled “Purpose”Form preserves browser submission and constraint-validation behavior while focusing the first invalid control. Form Error Summary provides an assertive announcement region for server, cross-field, or submission errors.
Default presentation: structural
Section titled “Default presentation: structural”The optional recipe supplies layout and stable structure without a strong visual treatment. Product typography, color, and emphasis remain consumer-owned.
Basic usage
Section titled “Basic usage”Anatomy
Section titled “Anatomy”The public component parts are listed in API surface below. Use only the parts needed by the example; compound components depend on their documented parent/child nesting.
State model
Section titled “State model”This component exposes no public controlled/uncontrolled state pair. Configure it through the props, events, native attributes, or parent-owned state documented in the API tables.
Keep inline Field Error messages associated with their controls through aria-describedby. Use Form Error Summary to complement those messages, not replace them.
Examples
Section titled “Examples”<Form onSubmit={save} onInvalid={trackInvalid}> <Label htmlFor="email">Email</Label> <Input id="email" name="email" type="email" required /> {errors.length > 0 && <FormErrorSummary>{errors.join(', ')}</FormErrorSummary>} <Button type="submit">Continue</Button></Form><Form @submit="save" @invalid="trackInvalid"> <Label for="email">Email</Label> <Input id="email" name="email" type="email" required /> <FormErrorSummary v-if="errors.length">{{ errors.join(', ') }}</FormErrorSummary> <Button type="submit">Continue</Button></Form><form simurghForm (submit)="save($event)" (invalidControl)="trackInvalid($event)"> <simurgh-label for="email">Email</simurgh-label> <simurgh-input id="email" name="email" type="email" [required]="true" /> <simurgh-form-error-summary *ngIf="errors.length"> {{ errors.join(', ') }} </simurgh-form-error-summary> <simurgh-button type="submit">Continue</simurgh-button></form>Real-world example: validated account form
Section titled “Real-world example: validated account form”Validate on submit, keep inline errors associated with controls, and put a concise summary first.
function submit(event: FormEvent<HTMLFormElement>) { event.preventDefault(); const values = Object.fromEntries(new FormData(event.currentTarget)); const nextErrors = validate(values); setErrors(nextErrors); if (Object.keys(nextErrors).length === 0) save(values);}<Form onSubmit={submit} onInvalid={(event) => event.preventDefault()}> {errors.email && ( <FormErrorSummary>Correct the email field.</FormErrorSummary> )} <Label htmlFor="account-email">Email</Label> <Input id="account-email" name="email" type="email" required invalid={Boolean(errors.email)} aria-describedby="email-error" /> <p id="email-error" role="alert"> {errors.email} </p></Form>;Vue uses @invalid; Angular uses (invalidControl) to receive the first invalid element. Preserve
the same aria-describedby relationship and summary in every adapter.
Accessibility
Section titled “Accessibility”Preserve the documented composition and accessible names when wrapping or restyling this component. See accessibility and RTL guidance for keyboard, focus, labeling, and directionality requirements.
API surface
Section titled “API surface”- React exports:
Form,FormErrorSummary - Vue exports:
Form,FormErrorSummary - Angular exports:
FormDirective,FormErrorSummaryComponent
Import these public symbols from the component subpath shown in Installation. Framework-specific props, events, slots, directives, methods, defaults, and native-attribute behavior belong in the API tables on this page; use the linked source only to verify the current implementation.
React API reference
An inherited-attributes entry means the component accepts the complete named React native interface, including its event handlers and ARIA and data attributes. Remaining attributes are forwarded to the rendered element unless the component behavior described on this page overrides them.
Inherited attributes: FormHTMLAttributes<HTMLFormElement> & RefAttributes<HTMLFormElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
focusInvalid | boolean | true |
ref | Ref<HTMLFormElement> | undefined | undefined |
FormErrorSummary
Section titled “FormErrorSummary”Inherited attributes: HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
ref | Ref<HTMLDivElement> | undefined | undefined |
Vue API reference
Boolean props without explicit defaults use Vue’s false default. Undeclared attributes follow
the fallthrough behavior stated for each component.
Vue attribute fallthrough is enabled for the rendered root.
| Prop | Type | Default / requirement |
|---|---|---|
focusInvalid | boolean | true |
| Event | Payload |
|---|---|
invalid | EventTarget | null |
Slots: default.
Exposed methods: none.
FormErrorSummary
Section titled “FormErrorSummary”Vue attribute fallthrough is enabled for the rendered root.
No declared props.
No emitted events.
Slots: default.
Exposed methods: none.
Angular API reference
Angular
Section titled “Angular”Inputs and outputs use their public template names. Public methods are callable through a template
reference or ViewChild. Native attributes apply to the documented template root or directive host;
they are not automatically forwarded through component hosts.
FormDirective
Section titled “FormDirective”Attribute directive selector: form[simurghForm]; behavior applies to its host element.
| Input | Type | Default / requirement |
|---|---|---|
focusInvalid | boolean | true |
| Output | Payload |
|---|---|
invalidControl | HTMLElement |
Content projection: none.
No public methods.
FormErrorSummaryComponent
Section titled “FormErrorSummaryComponent”Component selector: simurgh-form-error-summary. The template’s first native element is ng-content. Angular host bindings: { role: 'alert', 'aria-live': 'assertive', tabindex: '-1', 'data-slot': 'form-error-summary', }.
No inputs.
No outputs.
Content projection: default.
No public methods.
Composition contract
Section titled “Composition contract”Follow the framework example as a structural contract. Root components own shared state; parts that consume that state must stay under the root (or be attached to projected descendants in Angular). Parts described as conditional are optional until their corresponding interaction or semantic region is used. Do not render a state-consuming part by itself.
| Framework | Required parent/child relationship | Conditional parts | Supporting types |
|---|---|---|---|
| React | Render Form as the ancestor. Nest the listed parts inside that root so they can read its shared state/context. | FormErrorSummary are conditional parts: include only those needed by the documented anatomy. A trigger/control and its matching content/item are required when that interaction is used. | None. |
| Vue | Render Form as the ancestor. Nest the listed parts inside that root so they can read its shared state/context. | FormErrorSummary are conditional parts: include only those needed by the documented anatomy. A trigger/control and its matching content/item are required when that interaction is used. | None. |
| Angular | Create FormErrorSummaryComponent first. Attach listed directives to elements inside its projected content; nested component parts must remain inside it. | FormDirective are conditional parts: include only those needed by the documented anatomy. A trigger/control and its matching content/item are required when that interaction is used. | None. |
Accessible names, descriptions, and form labels remain required whenever the component’s purpose cannot otherwise be determined, even when the corresponding visual part is optional.
Framework parity and differences
Section titled “Framework parity and differences”The adapters target the same user-visible behavior and accessibility contract. Their public shapes follow each framework’s conventions and are not expected to be symbol-for-symbol identical.
| Concern | Contract |
|---|---|
| Public composition | All adapters export 2 public symbols, with framework-idiomatic names. |
| State and change events | No controlled state contract; use native attributes, inputs, or events documented above. |
| Children and content | React uses children; Vue uses the slots listed above; Angular uses the documented content projection selectors. |
| Native attributes | React forwards the named native interface; Vue follows the stated fallthrough rule; Angular attributes apply to the component host unless an input, directive, or documented native root consumes them. |
| Imperative access | React forwards native refs; Vue exposes no methods; Angular exposes no public methods. |
These differences are intentional adapter design. Behavioral or accessibility differences not stated on this page are parity defects rather than supported variations.
Form integration
Section titled “Form integration”This component is not a form control and does not contribute a named value to FormData. Use it
to structure or describe a form only when its purpose and accessibility guidance apply.
Supported states
Section titled “Supported states”The table distinguishes component behavior from application-owned presentation. “Not supported” means there is no public state contract for that adapter; do not invent one with an undocumented attribute. Keep status and error messages accessible when they are rendered outside the component.
| State | React | Vue | Angular |
|---|---|---|---|
| Loading | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Empty | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Invalid | Not supported by this component API; handle this state in surrounding application UI. | Supported with :invalid="true"; also associate visible error text. | Not supported by this component API; handle this state in surrounding application UI. |
| Read-only | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Disabled | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Error | Use the dedicated FormErrorSummary region. | Use the dedicated FormErrorSummary region. | Use the dedicated FormErrorSummaryComponent region. |
Styling contract
Styling contract
Section titled “Styling contract”The selectors below are used by the published component recipe or emitted consistently by an adapter. Treat these as the supported styling surface. Element order, anonymous wrappers, and undocumented descendants are implementation details and should not be targeted.
| Surface | Stable hooks |
|---|---|
| Recipe classes | No component-specific recipe class; this stylesheet currently imports shared tokens only. |
| Stable DOM parts | [data-slot="form-error-summary"] |
| Stable data attributes | [data-slot] |
| ARIA/state selectors used by the recipe | No ARIA state selector is used by this recipe. |
| CSS custom properties consumed | --simurgh-danger, --simurgh-radius, --simurgh-ring |
Prefer a semantic token override for theme-wide changes. Use the listed class or part selectors for a component-scoped override. When omitting recipe CSS, preserve state attributes and ARIA semantics even if your replacement styles use different selectors.
Customization
Section titled “Customization”Load the optional component stylesheet for the default recipe, override semantic tokens for broad theme changes, or omit the recipe CSS for headless styling. See theming and styling hooks for import order, selectors, dark mode, RTL, and reduced-motion guidance.
Last verified on 2026-08-13 against Simurgh registry 0.1.1.
Related components
Section titled “Related components”- Review the shared accessibility and RTL guidance and theming and styling hooks.
- Use the component chooser and component overview to compare related primitives.
- Inspect the registry manifest and framework source for React, Vue, or Angular.