Form primitives for Fict, modeled after @radix-ui/react-form. Accessible form fields with built-in client-side validation and message wiring.
Part of ui-primitives, a port of Radix Primitives to Fict.
pnpm add @fictjs/form fict/** @jsxImportSource fict */
import * as Form from '@fictjs/form'
export function Example() {
return (
<Form.Root>
<Form.Field name="email">
<Form.Label>Email</Form.Label>
<Form.Control type="email" required />
<Form.Message match="valueMissing">Please enter your email.</Form.Message>
<Form.Message match="typeMismatch">Please provide a valid email.</Form.Message>
</Form.Field>
<Form.Submit>Submit</Form.Submit>
</Form.Root>
)
}Form.Root(Root) —onClearServerErrors.Form.Field(Field) —name,serverInvalid; wires label, control, and messages together.Form.Label(Label),Form.Control(Control).Form.Message(Message) —matcha built-in validity key (e.g.valueMissing,typeMismatch) or a custom validation function.Form.ValidityState(ValidityState) — render-prop access to the field'sValidityState.Form.Submit(Submit).
- Components:
Form(Root),FormField(Field),FormLabel(Label),FormControl(Control),FormMessage(Message),FormValidityState(ValidityState),FormSubmit(Submit),createFormScope. - Types:
FormProps,FormFieldProps,FormLabelProps,FormControlProps,FormMessageProps,FormValidityStateProps,FormSubmitProps.
The API mirrors Radix, so the upstream Radix Form docs apply. See the ui-primitives overview and the architecture guide for the Fict-specific reactivity model.
MIT © Fict contributors.