This component requires the FyskProvider. See Quick Start →
Preview
Installation
Usage
Examples
Complete Feedback Loop
Showcasing the built-in overlays for submission and success messages.
Create an account
Features
Integrated State: The
stateprop handlesloading,success, anderrorglobally for the form, including blur/overlay effects.Auto-Aria: Components like
FormControlandFormMessageautomatically sync IDs andaria-describedbyfor a11y.Slot Implementation: Uses Radix Slot in
FormControlto safely inject props into any child input component.Hook Integration: Designed specifically to work with
react-hook-formandzodfor declarative validation.
Props
Form
| Prop | Type | Default | Description |
|---|---|---|---|
state | "idle" | "loading" | "success" | "error" | "idle" | The visual submission state. |
error | React.ReactNode | - | A manual/server error message to display at the top level. |
afterSubmission | React.ReactNode | - | Content/Message to show in a centered overlay on success. |
onCloseAfterSubmission | () => void | - | Callback when the success overlay is closed. |
LoadingIcon | React.ReactNode | - | Custom icon for the loading state. |
SuccessIcon | React.ReactNode | - | Custom icon for the success overlay. |
ErrorIcon | React.ReactNode | - | Custom icon for the error state. |
CloseIcon | React.ReactNode | - | Custom icon for closing the success overlay. |
FormField
A wrapper around react-hook-form's Controller that provides context to child components.
| Prop | Type | Default | Description |
|---|---|---|---|
control | Control | - | The form control object from useForm(). |
name | string | - | The field name (must match a key in your form schema). |
render | ({ field, fieldState, formState }) => React.ReactElement | - | Render function that receives field props and state. |
FormItem
A container for a single form field. Provides spacing and context for associating labels, descriptions, and error messages.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes for custom styling. |
FormLabel
A label for form inputs. Automatically associates with the input via the FormItem context and shows error styling when validation fails.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes for custom styling. |
FormControl
Wraps form inputs to provide proper accessibility attributes. Uses Radix Slot to merge props with the child element.
When used within a FormField, automatically adds unique ID for label association,
aria-describedbyfor description and error message, andaria-invalidwhen field has validation errors.
FormDescription
Provides additional context or instructions for a form field. Automatically associated with the input via aria-describedby.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes for custom styling. |
FormMessage
Displays validation error messages for a form field. When used within a FormField, automatically displays the error message from react-hook-form validation.
| Prop | Type | Default | Description |
|---|---|---|---|
state | "error" | "success" | "error" | The visual style of the message. |
children | React.ReactNode | - | Custom message content (overrides auto-detected error). |
Hooks
useFormField
Hook to access the current form field's state and metadata. Must be used within a FormField and FormItem component.
Returns:
| Property | Type | Description |
|---|---|---|
id | string | The unique ID for the form item. |
name | string | The field name registered with react-hook-form. |
formItemId | string | ID for the form item element. |
formDescriptionId | string | ID for the description element (for aria-describedby). |
formMessageId | string | ID for the error message element. |
error | FieldError | undefined | The current field error (if any). |
invalid | boolean | Whether the field has a validation error. |
isDirty | boolean | Whether the field value has been modified. |
isTouched | boolean | Whether the field has been touched/focused. |
All components accept standard props from their respective Radix and HTML elements.