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 🙏

© 2025 – Pkg Stats / Ryan Hefner

product-card-library

v1.0.0

Published

A customizable product card component library

Readme

Product Card Library

A beautiful, customizable product card component library for React applications.

Installation

For local development:

npm link

Then in your project:

npm link product-card-library

Usage

Basic Usage

import { ProductCard } from 'product-card-library';

function App() {
  return (
    <ProductCard
      image="https://example.com/product.jpg"
      title="Vintage Leather Bag"
      price={299}
      currency="$"
      description="Handmade leather totes, women's leather accessories"
      colors={[
        { color: '#8B4513', label: 'Brown' },
        { color: '#654321', label: 'Dark Brown' },
        { color: '#2C2C2C', label: 'Black' },
        { color: '#CD853F', label: 'Tan' }
      ]}
      sizes={[
        { value: 'cm', label: '40x12x30' },
        { value: 'cm', label: '42x25x37' }
      ]}
      onAddToCart={(product) => console.log('Added to cart:', product)}
      onBuyNow={(product) => console.log('Buy now:', product)}
    />
  );
}

Multiple Images with Color Selection

Images can change when colors are selected in two ways:

Method 1: Image per color

<ProductCard
  image="default-image.jpg"
  title="Multi-Color Bag"
  price={299}
  colors={[
    { 
      color: '#8B4513', 
      label: 'Brown',
      image: 'brown-bag.jpg'
    },
    { 
      color: '#2C2C2C', 
      label: 'Black',
      image: 'black-bag.jpg'
    }
  ]}
/>

Method 2: Images array

<ProductCard
  image="default-image.jpg"
  images={[
    'image-for-color-1.jpg',
    'image-for-color-2.jpg',
    'image-for-color-3.jpg'
  ]}
  title="Designer Bag"
  price={349}
  colors={[
    { color: '#FF0000', label: 'Red' },
    { color: '#0000FF', label: 'Blue' },
    { color: '#00FF00', label: 'Green' }
  ]}
/>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | image | string | required | Product image URL (fallback) | | images | string[] | - | Array of images for color variants | | title | string | required | Product title | | price | number \| string | required | Product price | | currency | string | '$' | Currency symbol | | description | string | undefined | Product description | | colors | ColorOption[] | [] | Available color options (can include images) | | sizes | SizeOption[] | [] | Available size options | | defaultColor | number | 0 | Default selected color index | | defaultSize | number | 0 | Default selected size index | | showQuantity | boolean | true | Show quantity selector | | onAddToCart | function | undefined | Add to cart callback | | onBuyNow | function | undefined | Buy now callback | | addToCartText | string | 'Add to cart' | Add to cart button text | | buyNowText | string | 'Buy now' | Buy now button text | | className | string | '' | Additional CSS class | | cardStyle | 'default' \| 'compact' \| 'detailed' | 'default' | Card variant | | width | number | undefined | Card width in pixels | | maxWidth | number | undefined | Card max-width in pixels | | minWidth | number | undefined | Card min-width in pixels | | imageHeight | number | undefined | Image height in pixels |

Card Styles

  • default: Standard card (max-width: 400px)
  • compact: Smaller card (max-width: 280px)
  • detailed: Larger card with description (max-width: 450px)

Custom Sizing

You can override the default dimensions using pixel values:

<ProductCard
  image="product.jpg"
  title="Custom Size Card"
  price={199}
  width={350}          // Fixed width: 350px
  imageHeight={300}    // Image height: 300px
  onAddToCart={handleCart}
/>

Size Props

  • width: Sets a fixed width in pixels
  • maxWidth: Sets maximum width in pixels (card can shrink but not grow beyond this)
  • minWidth: Sets minimum width in pixels (card can grow but not shrink below this)
  • imageHeight: Sets the image container height in pixels
// Responsive card with constraints
<ProductCard
  image="product.jpg"
  title="Flexible Card"
  price={299}
  minWidth={280}
  maxWidth={450}
  imageHeight={350}
  onAddToCart={handleCart}
/>

Development

# Install dependencies
npm install

# Build the library
npm run build

# Watch mode
npm run dev

License

MIT