npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-smart-fields

v1.1.6

Published

> A flexible, customizable, and developer-friendly component to generate dynamic form fields in React. Supports all HTML inputs, validation, and styling out of the box.

Readme

🧹 DynamicFields React Component

npm downloads license

A flexible, fully-styled dynamic form generator built with React and Tailwind CSS, supporting custom input types, validation, and class overrides. Ideal for building forms quickly with full control over design and behavior.


✨ Features

  • 📦 Supports text, number, checkbox, radio, and select fields
  • 💅 Fully customizable via Tailwind-compatible className props
  • 🧠 Built-in required field validation
  • 🧱 Extensible for advanced usage
  • 🌃 Full dark mode support
  • 🔄 Real-time onChange callback with live formData and errors

📦 Installation

Copy the DynamicFields.tsx file into your React project.

Make sure you have Tailwind CSS and React configured in your app.


🚀 Usage

Basic Example

import React from "react";
import DynamicFields from "./DynamicFields";

const fields = [
  {
    name: "username",
    label: "Username",
    type: "text",
    required: true,
  },
  {
    name: "email",
    label: "Email",
    type: "text",
    required: true,
  },
  {
    name: "gender",
    label: "Gender",
    type: "radio",
    required: true,
    options: [
      { label: "Male", value: "male" },
      { label: "Female", value: "female" },
    ],
  },
  {
    name: "country",
    label: "Country",
    type: "select",
    options: [
      { label: "USA", value: "us" },
      { label: "India", value: "in" },
    ],
  },
  {
    name: "subscribe",
    label: "Subscribe",
    type: "checkbox",
  }
];

function App() {
  const handleChange = (data) => {
    console.log("Form Data:", data);
  };

  return (
    <DynamicFields
      fields={fields}
      title="Sign Up"
      description="Please fill all fields"
      onChange={handleChange}
    />
  );
}

⚙️ Props

| Prop | Type | Required | Description | | -------------------- | ------------------------------------- | -------- | --------------------------------- | | fields | FieldConfig[] | ✅ Yes | List of field definitions | | onChange | (data: Record<string, any>) => void | ✅ Yes | Callback on value change | | title | string | ❌ No | Optional form title | | description | string | ❌ No | Optional description | | className | string | ❌ No | Wrapper div styling | | mainFieldClassName | string | ❌ No | Class for the fields wrapper | | inputClassName | string | ❌ No | Applies to text/number inputs | | labelClassName | string | ❌ No | Applies to all labels | | fieldClassName | string | ❌ No | Applied to each field wrapper div | | errorClassName | string | ❌ No | Error message styling | | selectClassName | string | ❌ No | select field styling | | checkboxClassName | string | ❌ No | Checkbox input styling | | radioClassName | string | ❌ No | Radio input styling | | optionClassName | string | ❌ No | Dropdown option styling |


🔧 FieldConfig (field definition)

Each field object can contain:

| Property | Type | Required | Notes | | ------------- | --------------------------------------------------------- | --------------------------------- | -------------------------------------- | | name | string | ✅ Yes | Unique key | | label | string | ❌ No | Display label | | type | "text", "number", "select", "radio", "checkbox" | ✅ Yes | Field type | | required | boolean | ❌ No | Show red asterisk and basic validation | | placeholder | string | ❌ No | Placeholder (for inputs/selects) | | description | string | ❌ No | Optional helper text | | options | { label: string; value: any; }[] | Required for select and radio | Dropdown/Radio values |


🎨 Class Mapping

Here's how classes are applied to each section:

| Section | Class Prop | Default Tailwind Example | | ------------------- | ------------------- | ---------------------------------- | | Wrapper div | className | bg-white dark:bg-gray-900 | | Label text | labelClassName | text-gray-800 dark:text-gray-200 | | Input fields | inputClassName | bg-white dark:bg-gray-800 | | Select dropdown | selectClassName | rounded-lg | | Radio buttons | radioClassName | rounded-full | | Checkbox | checkboxClassName | rounded | | Field container div | fieldClassName | w-full | | Dropdown options | optionClassName | hover:bg-gray-100 | | Error messages | errorClassName | text-red-500 |

You can override all styles with your own Tailwind classes!


🧪 Advanced Usage: Custom Styling Per Field

You can add inputClassName, labelClassName, or className inside each field:

{
  name: "email",
  label: "Email",
  type: "text",
  inputClassName: "border-purple-500",
  labelClassName: "text-purple-700 font-semibold",
  className: "mb-6",
}

🧑‍💻 Author

Name: Pratik Panchal GitHub: @Pratikpanchal25


📄 License

MIT — Free to use, modify and distribute.


🛠 Contributing

Pull requests are welcome! If you find bugs, feel free to open an issue.