logoRuru UI

Form

A form is used to collect and validate user input, commonly used in web applications.

Installation

npx ruru-ui-cli@latest add form

Usage

The Form component is a wrapper around react-hook-form that simplifies building forms with validation and accessibility.

Features

The Form component offers:

  • Composable components for building forms.
  • Controlled form fields via FormField.
  • Integration with react-hook-form for form state management.
  • Validation support using Zod.
  • Accessibility features like aria attributes and proper labeling.
  • Flexibility to style forms with any design system.
  • Built-in support for Radix UI components.
  • Works with various schema libraries (e.g., Zod).

Props

NameTypeDefaultDescription
childrenReact.ReactNodenullForm content, including form fields and buttons.
onSubmit(data: any) => voidnullThe function to handle form submission.
...propsReact.FormHTMLAttributes<HTMLFormElement>nullAdditional HTML attributes for the form element.

On this page