{"id":29112238,"url":"https://github.com/theprojectsx/react-dynamic-inputs","last_synced_at":"2026-03-07T13:32:09.160Z","repository":{"id":294634751,"uuid":"987587276","full_name":"TheProjectsX/react-dynamic-inputs","owner":"TheProjectsX","description":"Lightweight component for creating dynamic inputs","archived":false,"fork":false,"pushed_at":"2025-05-21T11:40:59.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T10:44:24.583Z","etag":null,"topics":["component","next","react","tailwind"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-dynamic-inputs","language":"JavaScript","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/TheProjectsX.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-21T09:42:24.000Z","updated_at":"2025-05-21T11:42:13.000Z","dependencies_parsed_at":"2025-05-21T10:55:22.900Z","dependency_job_id":"6b0d38d4-887e-4834-b87f-5d74d89a6ad8","html_url":"https://github.com/TheProjectsX/react-dynamic-inputs","commit_stats":null,"previous_names":["theprojectsx/react-dynamic-inputs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TheProjectsX/react-dynamic-inputs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheProjectsX%2Freact-dynamic-inputs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheProjectsX%2Freact-dynamic-inputs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheProjectsX%2Freact-dynamic-inputs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheProjectsX%2Freact-dynamic-inputs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheProjectsX","download_url":"https://codeload.github.com/TheProjectsX/react-dynamic-inputs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheProjectsX%2Freact-dynamic-inputs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268438271,"owners_count":24250654,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["component","next","react","tailwind"],"created_at":"2025-06-29T10:38:17.777Z","updated_at":"2026-03-07T13:32:09.101Z","avatar_url":"https://github.com/TheProjectsX.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Dynamic Inputs Component\n\nThe `react-dynamic-inputs` component allows you to create a dynamic list of input fields where users can add or remove input items. It is highly customizable with support for a custom layout, input validation, and dynamic item addition/removal.\n\n## Properties\n\n| Property            | Type                                                                                                                                                                                                                                  | Description                                                                                                                                                                     |\n| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `onChange`          | `(values: string[]) =\u003e void`                                                                                                                                                                                                          | A callback function that is triggered when the values in the input fields change. It receives an array of updated values as a parameter.                                        |\n| `children`          | `(inputProps: { handleOnChange: (e: React.ChangeEvent\u003cHTMLInputElement\u003e) =\u003e void; defaultValue: string }, removeButtonProps: { handleOnClick: (e: React.MouseEvent\u003cHTMLElement\u003e) =\u003e void; disabled: boolean }) =\u003e React.ReactElement` | A custom render function that allows you to pass custom input fields and remove buttons. The function receives `inputProps` and `removeButtonProps` for customization.          |\n| `defaultValues`     | `string[]`                                                                                                                                                                                                                            | Give Default Values of the Input(s). If given value count is smaller than defaultItemsCount, no default Value will be given. Useful when component rendering based on condition |\n| `defaultItemsCount` | `number`                                                                                                                                                                                                                              | The number of input fields to be initially displayed. Default is 2.                                                                                                             |\n| `minItems`          | `number`                                                                                                                                                                                                                              | The minimum number of input fields that should be allowed. Default is 0.                                                                                                        |\n| `maxItems`          | `number` \\| `null`                                                                                                                                                                                                                    | The maximum number of input fields allowed. If set to `null`, there's no upper limit.                                                                                           |\n| `className`         | `string`                                                                                                                                                                                                                              | A custom CSS class name that will be applied to the root element of the component.                                                                                              |\n| `style`             | `React.CSSProperties`                                                                                                                                                                                                                 | Inline styles that will be applied to the root element of the component.                                                                                                        |\n| `inputWrapperStyle` | `React.CSSProperties`                                                                                                                                                                                                                 | Inline styles that will be applied to each input wrapper element.                                                                                                               |\n| `addButtonLabel`    | `React.ReactNode` \\| `null`                                                                                                                                                                                                           | The label for the \"Add More\" button. Default is `\"Add More\"`.                                                                                                                   |\n| `customAddButton`   | `React.ReactElement\u003cany, any\u003e` \\| `null`                                                                                                                                                                                              | A custom React element to render as the \"Add More\" button. If provided, this will replace the default button.                                                                   |\n\n## Example\n\n```jsx\nimport React, { useState } from \"react\";\nimport DynamicInputs from \"react-dynamic-inputs\";\n\nconst App = () =\u003e {\n    const [inputValues, setInputValues] = useState([]);\n\n    const handleValuesChange = (values) =\u003e {\n        setInputValues(values);\n    };\n\n    return (\n        \u003cdiv\u003e\n            \u003ch1\u003eDynamic Inputs Example\u003c/h1\u003e\n\n            \u003cDynamicInputs\n                onChange={handleValuesChange}\n                defaultItems={3}\n                minItems={1}\n                maxItems={5}\n                addButtonLabel=\"Add More Fields\"\n                className=\"my-custom-class\"\n            /\u003e\n\n            \u003cdiv\u003e\n                \u003ch2\u003eCurrent Input Values:\u003c/h2\u003e\n                \u003cpre\u003e{JSON.stringify(inputValues, null, 2)}\u003c/pre\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n    );\n};\n\nexport default App;\n```\n\n### Key Notes:\n\n-   `onChange`: This will update the parent component with the current values whenever any input field is updated.\n-   `defaultItems`: You can specify how many input fields should be present when the component is first rendered.\n-   `minItems` \u0026 `maxItems`: These properties ensure that the number of inputs stays within the allowed limits.\n-   `customAddButton`: If you want to replace the default \"Add More\" button, pass in your custom button as a React element.\n\n## Custom Rendering\n\nYou can also pass a custom render function as the `children` prop, which allows you to have full control over how each input and remove button are rendered.\n\nExample of using `children`:\n\n```jsx\nimport React, { useState } from \"react\";\nimport DynamicInputs from \"react-dynamic-inputs\";\n\nconst App = () =\u003e {\n    const [inputValues, setInputValues] = useState([]);\n\n    const handleValuesChange = (values) =\u003e {\n        setInputValues(values);\n    };\n\n    return (\n        \u003cdiv\u003e\n            \u003ch1\u003eDynamic Input Example\u003c/h1\u003e\n\n            \u003cDynamicInputs\n                onChange={handleValuesChange}\n                defaultItems={2}\n                minItems={1}\n                maxItems={5}\n            \u003e\n                {(inputProps, removeButtonProps) =\u003e (\n                    \u003cdiv className=\"custom-input-wrapper\"\u003e\n                        \u003cinput {...inputProps} className=\"custom-input\" /\u003e\n                        \u003cbutton\n                            {...removeButtonProps}\n                            className=\"custom-remove-button\"\n                        \u003e\n                            Remove\n                        \u003c/button\u003e\n                    \u003c/div\u003e\n                )}\n            \u003c/DynamicInputs\u003e\n        \u003c/div\u003e\n    );\n};\n\nexport default App;\n```\n\nIn this example, the `children` function receives `inputProps` (for the input element) and `removeButtonProps` (for the remove button), allowing you to customize their appearance and behavior.\n\n## Example\n\nThere is also a useable Example in `example` folder. Feel free to check it out!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheprojectsx%2Freact-dynamic-inputs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheprojectsx%2Freact-dynamic-inputs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheprojectsx%2Freact-dynamic-inputs/lists"}