alepha@docs:~/docs/packages/@alepha-react$
cat form.md
1 min read
Last commit:

#@alepha/react - Form

#Installation

npm install @alepha/react

#Overview

React hooks for managing forms in Alepha applications.

This module provides a set of hooks to simplify form handling, validation, and submission in React applications built with Alepha.

It includes:

  • useForm: A hook for managing form state, validation, and submission.

#API Reference

#Hooks

Hooks provide a way to tap into various lifecycle events and extend functionality. They follow the convention of starting with use and return configured hook instances.

#useForm()

Custom hook to create a form with validation and field management. This hook uses TypeBox schemas to define the structure and validation rules for the form. It provides a way to handle form submission, field creation, and value management.

tsx
 1import { t } from "alepha"; 2  3const form = useForm({ 4  schema: t.object({ 5    username: t.text(), 6    password: t.text(), 7  }), 8  handler: (values) => { 9    console.log("Form submitted with values:", values);10  },11});12 13return (14  <form {...form.props}>15    <input {...form.input.username.props} />16    <input {...form.input.password.props} />17    <button type="submit">Submit</button>18  </form>19);
On This Page
No headings found...
ready
mainTypeScript
UTF-8packages_alepha_react_form.md