{"id":18715428,"url":"https://github.com/rawnly/react-generated-form","last_synced_at":"2026-05-01T16:34:34.551Z","repository":{"id":48587526,"uuid":"347218269","full_name":"rawnly/react-generated-form","owner":"rawnly","description":"React json based form generation.","archived":false,"fork":false,"pushed_at":"2022-07-18T20:28:00.000Z","size":389,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T23:03:36.939Z","etag":null,"topics":["form","json","react"],"latest_commit_sha":null,"homepage":"https://react.generated-form.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rawnly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-12T22:51:58.000Z","updated_at":"2023-11-21T00:20:51.000Z","dependencies_parsed_at":"2022-07-26T05:46:08.780Z","dependency_job_id":null,"html_url":"https://github.com/rawnly/react-generated-form","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawnly%2Freact-generated-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawnly%2Freact-generated-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawnly%2Freact-generated-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawnly%2Freact-generated-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rawnly","download_url":"https://codeload.github.com/rawnly/react-generated-form/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239577543,"owners_count":19662247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form","json","react"],"created_at":"2024-11-07T13:08:42.758Z","updated_at":"2025-11-10T05:30:21.242Z","avatar_url":"https://github.com/rawnly.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- omit in toc --\u003e\n# React JSON Form\n\u003e Create forms with ease\n\n\u003c!-- omit in toc --\u003e\n### Table of Contents\n- [Under The Hood](#under-the-hood)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Docs](#docs)\n  - [Field Props](#field-props)\n    - [`label: string`](#label-string)\n    - [`name: string`](#name-string)\n    - [`type?: \u003call the standard input types\u003e | time | coords | select | checkbox` - by default is `text`](#type-all-the-standard-input-types--time--coords--select--checkbox---by-default-is-text)\n    - [`placeholder?: string`](#placeholder-string)\n    - [`hint?: string`](#hint-string)\n    - [`noHint?: boolean`](#nohint-boolean)\n    - [`required?: boolean | string`](#required-boolean--string)\n    - [`validator: {}`](#validator-)\n    - [`when?: (fields: FormFields) =\u003e boolean`](#when-fields-formfields--boolean)\n    - [`watch?: string[]`](#watch-string)\n    - [`xs?: number`](#xs-number)\n    - [`md?: number`](#md-number)\n    - [`lg?: number`](#lg-number)\n- [Contributing](#contributing)\n\n\n\n## Under The Hood\nUnde the hood this packages uses `react-hook-form` to validate components and bootstrap for the style.\n\n\n## Installation\n\n```sh\n  npm install react-generated-form\n\n  # or\n\n  yarn add react-generated-form\n```\n\n## Usage\n```tsx\nimport { useForm, FormProvider } from 'react-hook-form'\n\n// Import your CSS on top\nimport 'bootstrap/dist/bootstrap.min.css';\n\n// Or just import component style\nimport 'react-generated-form/dist/style.css'\n\nimport {\n  GeneratedForm,\n  FormStructure,\n  GeneratedFormConfigProvider,\n} from 'react-generated-form'\n\ntype FormData = {\n  firstName: string;\n  lastName: string;\n  email: string;\n  password: string;\n}\n\nconst formStructure : FormStructure\u003cFormData\u003e = [\n  // Section 1, Name and Surname\n  [\n    {\n      name: 'firstName', // keyof FormData\n      label: 'First Name',\n      placeholder: 'John',\n      required: true, // by default the error label will be `Field ${label} is required!`\n      groupClassName: 'w-2/4'\n    },\n    {\n      name: 'lastName',\n      label: 'Last Name',\n      placeholder: 'John',\n      required: true,\n      groupClassName: 'w-2/4'\n    },\n  ],\n  // Section 2, Email\n  [\n    {\n      name: 'email',\n      label: 'Email',\n      placeholder: 'you@domain.me',\n      required: true,\n      type: 'email', // Specify input type,\n    }\n  ],\n\n  // Section 3, Password and Validation\n  [\n    {\n      name: 'password',\n      label: 'Password',\n      placeholder: '*********',\n      hint: 'Must be 8-16 characters.', // You can also add an hint\n      required: true,\n      groupClassName: 'w-2/4',\n      validator: { // refer to react-hook-form API\n        minLength: {\n          value: 8,\n          message: 'The password must be at least 8 characters.'\n        },\n        maxLength: {\n          value: 16,\n          message: 'The password must be maximum 16 characters.'\n        }\n      }\n    },\n    {\n      // with the suffix `_confirm` the generated form\n      // auto validates the fields, so you don't need to manually check values.\n      name: 'password_confirm',\n      label: 'Confirm Password',\n      required: true,\n      groupClassName: 'w-2/4'\n    }\n  ]\n]\n\n  function Form() {\n    const methods = useForm\u003cFormData\u003e({\n      mode: 'onSubmit'\n    })\n\n    const onSubmit = useCallback(...);\n\n    return (\n      \u003cform onSubmit={methods.handleSubmit(onSubmit)}\u003e\n        \u003cFormProvider {...methods}\u003e\n          \u003cGeneratedForm\u003cFormData\u003e\n            structure={formStructure}\n          /\u003e\n        \u003c/FormProvider\u003e\n\n        \u003cdiv className='form-group'\u003e\n          \u003cbutton type='submit'\u003e\n            Sign Up\n          \u003c/button\u003e\n        \u003c/div\u003e\n      \u003c/form\u003e\n    )\n  }\n\n\n  {/* Later */}\n  {/* You can change elements classnames */}\n\n  ReactDOM.render(\n    \u003cGeneratedFormConfigProvider\n      value={{\n        accent: 'purple',\n        input: 'rounded-md shadow-sm border border-gray-300 block w-full sm:text-sm p-2',\n        inputGroup: 'w-full flex mb-2 flex-col items-start justify-start',\n        label: 'block text-sm font-medium text-gray-700 mb-1',\n        hint: 'mt-2 text-sm text-gray-500',\n        row: 'flex flex-wrap mb-3',\n        error: 'mt-2 text-sm text-red-600'\n      }}\n    \u003e\n      \u003cForm /\u003e\n    \u003c/GeneratedFormConfigProvider\u003e\n  )\n]\n```\n\n\n## Docs\n\u003e (work in progress)\n### Field Props\n#### `label: string`\nThe label of the input\n#### `name: string`\nName of the input (will be the key in the json)\n#### `type?: \u003call the standard input types\u003e | time | coords | select | checkbox` - by default is `text`\nType of the input, some types such as the `email` have special validation.\n#### `placeholder?: string`\nPlaceholder of the input\n#### `hint?: string`\nA small text under the input\n#### `noHint?: boolean`\nHide the hint\n#### `required?: boolean | string`\nMark a field as required, the default error text will be `Field {label} is required.`\n#### `validator: {}`\nSome options to validate the value\n#### `when?: (fields: FormFields) =\u003e boolean`\nThe input will be hidden until this function returns true\n#### `watch?: string[]`\nTell the input which values to watch for the `when` function.\n#### `xs?: number`\nColumn size on mobile\n#### `md?: number`\nColumn size on tablet\n#### `lg?: number`\nColumn size on desktop\n\n## Contributing\nFeel free to contribute in any way, or just open an issue ✌️\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawnly%2Freact-generated-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frawnly%2Freact-generated-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawnly%2Freact-generated-form/lists"}