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

@abhimanew2000/react-button-factory

v1.0.8

Published

A highly customizable React button component with Factory Pattern

Readme

React Button Factory

A highly customizable React button component built with Factory Pattern and Abstraction.

npm version

Important: Tailwind CSS Required

This package uses Tailwind CSS for styling. You must have Tailwind configured in your project!

Installation

npm install @abhimanew2000/react-button-factory

Tailwind CSS Setup

1. Install Tailwind (if not already installed)

npm install -D tailwindcss
npx tailwindcss init

2. Configure Tailwind

Update your tailwind.config.js:

export default {
  content: [
    "./src/**/*.{js,jsx,ts,tsx}",
    "./node_modules/@abhimanew2000/react-button-factory/dist/**/*.{js,cjs}", //  Add this!
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

3. Import Tailwind CSS

In your main CSS file (e.g., src/index.css):

@tailwind base;
@tailwind components;
@tailwind utilities;

4. Restart Dev Server

After changing config, restart your dev server:

npm run dev

Usage

import { Button } from '@abhimanew2000/react-button-factory';

function App() {
  return (
    <div>
      <Button variant="primary" size="large">
        Click Me
      </Button>
    </div>
  );
}

Props

Visual Properties

| Prop | Type | Default | Description | |------|------|---------|-------------| | variant | 'primary' | 'secondary' | 'danger' | 'success' | 'outline' | 'primary' | Button color | | size | 'small' | 'medium' | 'large' | 'medium' | Button size | | shape | 'rounded' | 'square' | 'pill' | 'rounded' | Border radius | | weight | 'light' | 'normal' | 'bold' | 'normal' | Font weight | | shadow | 'none' | 'small' | 'medium' | 'large' | 'none' | Shadow depth |

Content Properties

| Prop | Type | Description | |------|------|-------------| | children | ReactNode | Button text/content (required) | | icon | ReactNode | Icon element | | iconPosition | 'left' | 'right' | Icon position |

Behavioral Properties

| Prop | Type | Default | Description | |------|------|---------|-------------| | onClick | () => void | - | Click handler | | disabled | boolean | false | Disabled state | | loading | boolean | false | Loading state | | type | 'button' | 'submit' | 'reset' | 'button' | HTML button type | | className | string | '' | Additional classes |

Examples

Different Variants

<Button variant="primary">Primary</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="danger">Danger</Button>
<Button variant="success">Success</Button>
<Button variant="outline">Outline</Button>

Different Sizes

<Button size="small">Small</Button>
<Button size="medium">Medium</Button>
<Button size="large">Large</Button>

Different Shapes

<Button shape="square">Square</Button>
<Button shape="rounded">Rounded</Button>
<Button shape="pill">Pill</Button>

With Icons

<Button icon={<SaveIcon />} iconPosition="left">
  Save
</Button>

<Button icon={<TrashIcon />} iconPosition="right">
  Delete
</Button>

Loading State

<Button variant="primary" loading>
  Saving...
</Button>

Combined Properties

<Button 
  variant="danger" 
  size="large"
  shape="pill"
  weight="bold"
  shadow="large"
>
  Delete Account
</Button>

Troubleshooting

Buttons have no styling

Problem: Classes present but no colors/styles

Solution:

  1. Make sure Tailwind CSS is installed
  2. Add package path to tailwind.config.js content array
  3. Restart dev server after config change

Only one variant works

Problem: Only primary button has color

Solution: Use safelist in your Tailwind config:

export default {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
  safelist: [
    'bg-blue-600', 'bg-gray-600', 'bg-red-600', 'bg-green-600',
    'hover:bg-blue-700', 'hover:bg-gray-700', 'hover:bg-red-700', 'hover:bg-green-700',
  ],
}

Architecture

Built with:

  • Factory Pattern for flexible creation
  • Abstraction for easy extension
  • TypeScript for type safety
  • Tailwind CSS for styling

License

MIT

Author

abhimanew ([email protected])

Links


Made with using Factory Pattern + Abstraction