pricecn

Pricing Table

A set of pricing cards that detail the products you offer. Generates from a simple JSON product schema.

Installation

To install, run:

npx shadcn@latest add https://pricecn.com/clean/pricing-table.json
pnpm dlx shadcn@latest add https://pricecn.com/clean/pricing-table.json
yarn dlx shadcn@latest add https://pricecn.com/clean/pricing-table.json
bunx --bun shadcn@latest add https://pricecn.com/clean/pricing-table.json

This will download the pricing-table component into your /components directory.
You can swap clean for classic or dev if you want to use a different style. View them all at pricecn.com.


Define Your Product Schema

Pricing components can be involved and tricky to manage on the frontend, especially when pricing changes happen.
pricing-table can automatically generate based on a simple product schema you define.

interface ProductItem {
  primaryText: string;
  secondaryText?: string;
}

interface Product {
  id: string, // An ID you'll pass into a <PricingCard> to render it.
  name: string, // The name of the product (e.g., Pro).
  description?: string, // Product description.
  everythingFrom?: string, // Renders an "Everything from X, and" string.

  buttonText?: string, // Text for the <PricingCard> button.
  buttonUrl?: string, // Optional URL for the button.

  recommendedText?: string, // For emphasized products (e.g., "Best Value").

  price: ProductItem, // Primary pricing details, e.g., "$10/month".
  priceAnnual?: ProductItem, // Optional annual pricing details.

  items: ProductItem[], // List of features or items included in the product.
}

LLMs are good at auto-generating this schema from a screenshot!


Usage

An example usage of <PricingTable /> will be downloaded as components/pricing/example.tsx.
This file demonstrates how to define your products and pass them into the PricingTable component.

import { PricingTable, PricingCard } from "./pricing-table";
import type { Product } from "@/types/product";

export const data: ProductsSchema = {
  "$schema": "https://www.pricecn.com/schemas/pricing.schema.json",
  "products": [{
    id: "hobby",
    name: "Hobby",
    description: "For personal projects and small-scale applications.",
    price: { primaryText: "Free", secondaryText: "up to 3 users" },
    buttonText: "Start deploying",
    items: [
      { primaryText: "Deploy full-stack apps in minutes" },
      { primaryText: "Fully-managed datastores" },
      // ...more features
    ]
  }, // ...more products
  ]
};

export const PricingTableExample = () => (
  <PricingTable products={data.products} showFeatures={true}>
    <PricingCard productId="hobby" />
    <PricingCard productId="professional" />
    <PricingCard
      productId="enterprise"
      buttonProps={{
        onClick: () => {
          console.log("Button Clicked");
        },
      }}
    />
  </PricingTable>
);

<PricingCard> can also take in buttonProps, allowing you to define an onClick() function.


Coming Soon

  • Paywalls
  • Billing pages
  • Feature tables
  • Usage meters

Last updated on