ink-zone / fomir

A Schema-First Form Library

Home Page:https://fomir.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fomir

A Schema-First form library

npm Minzipped size NPM Downloads code style: prettier

Installation

npm install fomir

Quick Start

function BasicForm() {
  const form = useForm({
    onSubmit(values) {
      alert(JSON.stringify(values, null, 2))
      console.log('values', values)
    },
    children: [
      {
        label: 'First Name',
        name: 'firstName',
        component: 'Input',
        value: '',
      },
      {
        label: 'Last Name',
        name: 'lastName',
        component: 'Input',
        value: '',
      },
      {
        component: 'Submit',
        text: 'submit',
      },
    ],
  })

  return <Form form={form} />
}

Markup Schema

Fomir also supports building form using markup.

function BasicForm() {
  const form = useForm({
    onSubmit(values) {
      alert(JSON.stringify(values, null, 2))
      console.log('values', values)
    },
  })

  return (
    <Form form={form}>
      <h2>Basic Info</h2>
      <Box bgGray100 rounded p3 mb4>
        <Field component="Input" label="First Name" name="firstName" />
        <Field component="Input" label="Last Name" name="lastName" />
      </Box>

      <h2>Extra Info</h2>
      <Box bgGray100 rounded p3 mb4>
        <Field component="Input" label="Email" name="email" />
        <Field component="Textarea" label="Bio" name="bio" />
      </Box>

      <button>Submit</button>
    </Form>
  )
}

Documentation

Documentation website: fomir.vercel.app

Development

License

MIT License

About

A Schema-First Form Library

https://fomir.vercel.app

License:MIT License


Languages

Language:TypeScript 82.3%Language:CSS 9.9%Language:JavaScript 7.7%Language:Shell 0.1%