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

prop-comb

v1.0.0-alpha.4

Published

Create React components from a given combinations of props.

Readme

prop-comb

Create React components from a given combinations of props.


version downloads MIT License

PRs Welcome Code of Conduct

Watch on GitHub Star on GitHub


Installation

yarn add prop-comb
# or
npm install prop-comb

Usage example

Let's say you use a Button component from a UI library, with specific props all the time.

To avoid declaring the same props everywhere, you have the following options:

  1. Modify the global theme, so the default Button has all the styling you need. The drawback here is that you can only define one default Button with custom styling.
  2. Create a file, that exports different buttons, with hardcoded props on them. It may be a better approach, but you still have to iterate over the possible combinations you need manually.

Something like this:

// Buttons.js
import {Button} from "your-ui-library"

export const ButtonPrimary = props => <Button color="primary" {...props}/>
export const ButtonLarge = props => <Button size="large" {...props}/>

export const ButtonPrimaryLarge = props => <Button color="primary" size="large" {...props}/>
// or the following, whatever you prefer
export const ButtonLargePrimary = props => <Button size="large" color="primary" {...props}/>

This is where prop-comb comes into the picture:

// Buttons.js
import {Button} from "your-ui-library"
import propComb from "prop-comb"

export default propComb(Button, {
  color: ["primary"],
  size: ["large"]
})

And the component where you would like to use the Button

import {Button as UIButton} from "your-ui-library"
import Button from "./Buttons" // with prop-comb

import {ButtonPrimary, ButtonPrimaryLarge} from "./Buttons" // without prop-comb

const Component = () => {
  return (
    <div>
      <Button.primary>Primary button</Button.primary>
      <Button.primary.large>Primary large button</Button.primary.large>

      <ButtonPrimary>Primary button</ButtonPrimary>
      <ButtonPrimaryLarge >Primary large button</ButtonPrimaryLarge>
    </div>
  )
}

The difference is not huge, but if you use a big combinations of components all the time, it may result in less writing.

prop-combs will create all the combinations for you, automatically.

Under the hood

But how can Button.primary be both a JSX element, and an object containing other JSX elements at the same time?

The answer is ES6 Proxy. This means, you will only be able to use this module in ES6 environments.

The propComb function works like this:

When you access for example Button.primary, and use it as a JSX Element, it will be called as a function under the hood. This is caught by the apply() trap in the Proxy, that will than return a JSX element for you. If you go deeper, and try to get a property by dot notation, the proxy will trap it with get(). It does that recursivly, this is how can you go deeper than one "layer".