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

@hugn10204/cart-lib-ui

v1.0.1

Published

A beautiful React cart library with Material-UI components

Readme

🛒 Cart Lib UI

npm version License: MIT

A beautiful, production-ready React shopping cart library built with Material-UI components. Perfect for e-commerce applications with elegant design and full TypeScript support.

✨ Features

  • 🎨 Beautiful UI - Styled with Material-UI for a modern, professional look
  • 📦 Complete Cart Management - Add, remove, update quantities, and clear cart
  • 🎯 TypeScript Support - Full type definitions included
  • 🪝 React Hooks - Easy-to-use useCart hook for cart state management
  • 🎭 Customizable - Flexible props for styling and behavior
  • 📱 Responsive - Works perfectly on all screen sizes
  • 🚀 Lightweight - Minimal bundle size with tree-shaking support

📦 Installation

npm install @hugn10204/cart-lib-ui

Peer Dependencies

Make sure you have these installed:

npm install react react-dom @mui/material @emotion/react @emotion/styled @mui/icons-material

🚀 Quick Start

import { CartProvider, CartList, CartAddForm } from "@hugn10204/cart-lib-ui";

function App() {
  return (
    <CartProvider>
      <div>
        <h1>My Shop</h1>
        <CartAddForm />
        <CartList showCheckoutButton onCheckout={() => alert("Proceeding to checkout!")} />
      </div>
    </CartProvider>
  );
}

📚 Components

CartProvider

Wrap your app with CartProvider to enable cart functionality.

import { CartProvider } from "@hugn10204/cart-lib-ui";

<CartProvider initialItems={[]} onCartChange={(state) => console.log("Cart updated:", state)}>
  {/* Your app */}
</CartProvider>;

Props:

  • initialItems?: CartItem[] - Initial cart items
  • onCartChange?: (state: CartState) => void - Callback when cart changes

useCart Hook

Access cart state and methods anywhere in your app.

import { useCart } from "@hugn10204/cart-lib-ui";

function MyComponent() {
  const { items, totalPrice, addItem, removeItem, updateQuantity, clearCart } = useCart();

  return (
    <div>
      <p>Total: ${totalPrice.toFixed(2)}</p>
      <button onClick={clearCart}>Clear Cart</button>
    </div>
  );
}

CartList

Display all cart items with totals and checkout button.

import { CartList } from "@hugn10204/cart-lib-ui";

<CartList
  showTotal={true}
  showCheckoutButton={true}
  onCheckout={() => console.log("Checkout clicked")}
  emptyMessage="Your cart is empty"
  checkoutButtonText="Checkout"
/>;

CartItem

Display a single cart item (used internally by CartList, can be used standalone).

import { CartItem } from "@hugn10204/cart-lib-ui";

<CartItem
  item={myItem}
  onRemove={(id) => console.log("Remove", id)}
  onUpdateQuantity={(id, qty) => console.log("Update", id, qty)}
  showRemoveButton={true}
  showQuantityControls={true}
/>;

CartAddForm

Form to add new products to cart.

import { CartAddForm } from "@hugn10204/cart-lib-ui";

<CartAddForm onAdd={(item) => console.log("Added:", item)} buttonText="Add to Cart" />;

ProductCard

Beautiful product card with add to cart button.

import { ProductCard, useCart } from "@hugn10204/cart-lib-ui";

function Products() {
  const { addItem } = useCart();

  return (
    <ProductCard
      id="1"
      name="Awesome Product"
      price={29.99}
      image="https://example.com/product.jpg"
      description="This is an amazing product"
      onAddToCart={addItem}
      addButtonText="Add to Cart"
    />
  );
}

🎨 Styling

All components use Material-UI and respect your MUI theme. Customize by wrapping with ThemeProvider:

import { createTheme, ThemeProvider } from "@mui/material/styles";
import { CartProvider, CartList } from "@hugn10204/cart-lib-ui";

const theme = createTheme({
  palette: {
    primary: {
      main: "#1976d2",
    },
  },
});

function App() {
  return (
    <ThemeProvider theme={theme}>
      <CartProvider>
        <CartList />
      </CartProvider>
    </ThemeProvider>
  );
}

📖 TypeScript

Full TypeScript support with exported types:

import type { CartItemType, CartState, CartContextType } from "@hugn10204/cart-lib-ui";

const myItem: CartItemType = {
  id: "1",
  name: "Product",
  price: 19.99,
  quantity: 2,
  image: "https://example.com/image.jpg",
  description: "Product description",
};

🔧 API Reference

CartItem Type

interface CartItem {
  id: string | number;
  name: string;
  price: number;
  quantity: number;
  image?: string;
  description?: string;
}

Cart Methods

  • addItem(item) - Add or increase quantity of an item
  • removeItem(id) - Remove item from cart
  • updateQuantity(id, quantity) - Update item quantity
  • clearCart() - Remove all items
  • getItem(id) - Get specific item by ID

📄 License

MIT © Hung Le

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

🐛 Issues

Found a bug? Please open an issue on GitHub.


Made with ❤️ using React, TypeScript, and Material-UI