{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pricing-table",
  "title": "Pricing Table",
  "description": "Pricing plans side by side with a monthly / yearly switch, prices that roll when the period changes, a highlighted plan with a badge, included and excluded features, and a custom-price plan for enterprise.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/pricing-table/pricing-table.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type Billing = \"monthly\" | \"yearly\";\n\nexport interface PricingFeature {\n  label: string;\n  /** false shows the feature crossed out (not in this plan). Defaults to true. */\n  included?: boolean;\n}\n\nexport interface PricingPlan {\n  id: string;\n  name: string;\n  description?: string;\n  /**\n   * A number is the same price for both billing periods. An object gives the monthly price and the\n   * per-month price when paid yearly. null shows \"Custom\" (for an enterprise plan).\n   */\n  price: number | { monthly: number; yearly: number } | null;\n  features: (string | PricingFeature)[];\n  /** Button label. Defaults to \"Get started\", or \"Contact sales\" for a custom price. */\n  cta?: string;\n  /** Turns the button into a link. */\n  href?: string;\n  /** Draws the plan raised, with an accent border and the badge. */\n  highlighted?: boolean;\n  /** Small label above the name, e.g. \"Most popular\". Shown on the highlighted plan by default. */\n  badge?: string;\n}\n\nexport interface PricingTableProps {\n  plans?: PricingPlan[];\n  billing?: Billing;\n  defaultBilling?: Billing;\n  onBillingChange?: (billing: Billing) => void;\n  /** Called when a plan's button is pressed (plans without href). */\n  onSelect?: (planId: string, billing: Billing) => void;\n  /** Hide the monthly / yearly switch, for plans that only have one price. */\n  showBillingToggle?: boolean;\n  /** Pill next to \"Yearly\". Pass \"\" to hide it. */\n  yearlyNote?: string;\n  currency?: string;\n  /** Text after the price, e.g. \"/month\" or \"/seat\". */\n  period?: string;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst DEFAULT_PLANS: PricingPlan[] = [\n  {\n    id: \"hobby\",\n    name: \"Hobby\",\n    description: \"For side projects and trying things out.\",\n    price: 0,\n    cta: \"Start for free\",\n    features: [\"1 project\", \"Up to 1,000 events / month\", \"Community support\", { label: \"Custom domain\", included: false }, { label: \"Team members\", included: false }],\n  },\n  {\n    id: \"pro\",\n    name: \"Pro\",\n    description: \"For growing products that need more room.\",\n    price: { monthly: 24, yearly: 19 },\n    highlighted: true,\n    badge: \"Most popular\",\n    features: [\"Unlimited projects\", \"Up to 100,000 events / month\", \"Email support\", \"Custom domain\", { label: \"Team members\", included: false }],\n  },\n  {\n    id: \"team\",\n    name: \"Team\",\n    description: \"For teams that ship together.\",\n    price: { monthly: 59, yearly: 49 },\n    features: [\"Everything in Pro\", \"Up to 1M events / month\", \"Priority support\", \"Custom domain\", \"Up to 10 team members\"],\n  },\n];\n\nconst PALETTES = {\n  dark: {\n    text: \"#F5F4F1\",\n    muted: \"rgba(245,244,241,0.55)\",\n    faint: \"rgba(245,244,241,0.3)\",\n    card: \"#0E0E0E\",\n    cardHi: \"#141414\",\n    border: \"rgba(255,255,255,0.1)\",\n    borderHi: \"rgba(245,244,241,0.55)\",\n    track: \"rgba(255,255,255,0.05)\",\n    thumb: \"#F5F4F1\",\n    onThumb: \"#0A0A0A\",\n    primary: \"#F5F4F1\",\n    onPrimary: \"#0A0A0A\",\n    secondary: \"rgba(255,255,255,0.06)\",\n    secondaryHover: \"rgba(255,255,255,0.11)\",\n    pill: \"rgba(63,191,127,0.14)\",\n    pillText: \"#5FD99B\",\n    ok: \"#5FD99B\",\n  },\n  light: {\n    text: \"#0A0A0A\",\n    muted: \"rgba(10,10,10,0.55)\",\n    faint: \"rgba(10,10,10,0.3)\",\n    card: \"#FFFFFF\",\n    cardHi: \"#FFFFFF\",\n    border: \"rgba(10,10,10,0.1)\",\n    borderHi: \"rgba(10,10,10,0.75)\",\n    track: \"rgba(10,10,10,0.05)\",\n    thumb: \"#0A0A0A\",\n    onThumb: \"#FFFFFF\",\n    primary: \"#0A0A0A\",\n    onPrimary: \"#FFFFFF\",\n    secondary: \"rgba(10,10,10,0.05)\",\n    secondaryHover: \"rgba(10,10,10,0.09)\",\n    pill: \"rgba(31,157,92,0.12)\",\n    pillText: \"#1F9D5C\",\n    ok: \"#1F9D5C\",\n  },\n};\n\ntype Palette = (typeof PALETTES)[\"dark\"];\n\nfunction priceFor(plan: PricingPlan, billing: Billing): number | null {\n  if (plan.price === null) return null;\n  if (typeof plan.price === \"number\") return plan.price;\n  return plan.price[billing];\n}\n\nfunction formatPrice(n: number) {\n  return Number.isInteger(n) ? n.toLocaleString(\"en-US\") : n.toFixed(2);\n}\n\nfunction Check({ color }: { color: string }) {\n  return (\n    <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={color} strokeWidth={2.4} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n      <path d=\"m5 12.5 4.5 4.5L19 7.5\" />\n    </svg>\n  );\n}\n\nfunction Cross({ color }: { color: string }) {\n  return (\n    <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={color} strokeWidth={2.2} strokeLinecap=\"round\" aria-hidden=\"true\">\n      <path d=\"M7 7l10 10M17 7 7 17\" />\n    </svg>\n  );\n}\n\nfunction BillingToggle({ value, onChange, note, p, reduce }: { value: Billing; onChange: (b: Billing) => void; note: string; p: Palette; reduce: boolean | null }) {\n  const options: Billing[] = [\"monthly\", \"yearly\"];\n  const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    if (e.key !== \"ArrowLeft\" && e.key !== \"ArrowRight\") return;\n    e.preventDefault();\n    const next = value === \"monthly\" ? \"yearly\" : \"monthly\";\n    onChange(next);\n    refs.current[options.indexOf(next)]?.focus();\n  };\n\n  return (\n    <div role=\"radiogroup\" aria-label=\"Billing period\" onKeyDown={onKeyDown} className=\"relative inline-flex items-center rounded-full p-1\" style={{ background: p.track, border: `1px solid ${p.border}` }}>\n      {options.map((opt, i) => {\n        const active = value === opt;\n        return (\n          <button\n            key={opt}\n            ref={(el) => {\n              refs.current[i] = el;\n            }}\n            type=\"button\"\n            role=\"radio\"\n            aria-checked={active}\n            tabIndex={active ? 0 : -1}\n            onClick={() => onChange(opt)}\n            className=\"relative z-10 flex h-9 items-center gap-2 rounded-full px-4 text-sm font-medium outline-none transition-colors focus-visible:ring-2\"\n            style={{ color: active ? p.onThumb : p.muted }}\n          >\n            {active && (\n              <motion.span\n                layoutId=\"pricing-table-thumb\"\n                className=\"absolute inset-0 -z-10 rounded-full\"\n                style={{ background: p.thumb }}\n                transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 420, damping: 34 }}\n              />\n            )}\n            {opt === \"monthly\" ? \"Monthly\" : \"Yearly\"}\n            {opt === \"yearly\" && note && (\n              <span className=\"rounded-full px-2 py-0.5 text-[11px] font-semibold\" style={{ background: active ? \"rgba(127,127,127,0.18)\" : p.pill, color: active ? p.onThumb : p.pillText }}>\n                {note}\n              </span>\n            )}\n          </button>\n        );\n      })}\n    </div>\n  );\n}\n\nfunction Price({ value, currency, period, billing, yearlyTotal, p, reduce }: { value: number | null; currency: string; period: string; billing: Billing; yearlyTotal: number | null; p: Palette; reduce: boolean | null }) {\n  if (value === null) {\n    return (\n      <div className=\"flex h-[72px] flex-col justify-center\">\n        <span className=\"text-4xl font-semibold tracking-tight\" style={{ color: p.text }}>\n          Custom\n        </span>\n        <span className=\"mt-1 text-xs\" style={{ color: p.muted }}>\n          Tailored to your volume\n        </span>\n      </div>\n    );\n  }\n  return (\n    <div className=\"flex h-[72px] flex-col justify-center\">\n      <div className=\"flex items-baseline\">\n        <span className=\"text-4xl font-semibold tracking-tight\" style={{ color: p.text }}>\n          {currency}\n        </span>\n        <span className=\"relative inline-flex overflow-hidden\">\n          <AnimatePresence mode=\"popLayout\" initial={false}>\n            <motion.span\n              key={value}\n              className=\"text-4xl font-semibold tabular-nums tracking-tight\"\n              style={{ color: p.text }}\n              initial={reduce ? { opacity: 0 } : { y: \"70%\", opacity: 0 }}\n              animate={{ y: 0, opacity: 1 }}\n              exit={reduce ? { opacity: 0 } : { y: \"-70%\", opacity: 0 }}\n              transition={{ duration: 0.28, ease: [0.22, 1, 0.36, 1] }}\n            >\n              {formatPrice(value)}\n            </motion.span>\n          </AnimatePresence>\n        </span>\n        <span className=\"ml-1.5 text-sm\" style={{ color: p.muted }}>\n          {period}\n        </span>\n      </div>\n      <span className=\"mt-1 h-4 text-xs\" style={{ color: p.muted }}>\n        {value === 0 ? \"Free forever\" : billing === \"yearly\" && yearlyTotal !== null ? `${currency}${formatPrice(yearlyTotal)} billed yearly` : \"Billed monthly\"}\n      </span>\n    </div>\n  );\n}\n\nexport function PricingTable({\n  plans = DEFAULT_PLANS,\n  billing: billingProp,\n  defaultBilling = \"yearly\",\n  onBillingChange,\n  onSelect,\n  showBillingToggle = true,\n  yearlyNote = \"Save 20%\",\n  currency = \"$\",\n  period = \"/month\",\n  theme = \"dark\",\n  className,\n}: PricingTableProps) {\n  const p = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const [inner, setInner] = React.useState<Billing>(defaultBilling);\n  const billing = billingProp ?? inner;\n  const setBilling = (b: Billing) => {\n    if (billingProp === undefined) setInner(b);\n    onBillingChange?.(b);\n  };\n\n  const cols = plans.length >= 4 ? \"lg:grid-cols-4 md:grid-cols-2\" : plans.length === 3 ? \"md:grid-cols-3\" : plans.length === 2 ? \"md:grid-cols-2\" : \"\";\n\n  return (\n    <div className={cn(\"w-full\", className)} style={{ color: p.text }}>\n      {showBillingToggle && (\n        <div className=\"mb-8 flex justify-center\">\n          <BillingToggle value={billing} onChange={setBilling} note={yearlyNote} p={p} reduce={reduce} />\n        </div>\n      )}\n\n      <div className={cn(\"grid grid-cols-1 items-stretch gap-4\", cols)}>\n        {plans.map((plan, i) => {\n          const value = priceFor(plan, billing);\n          const yearlyTotal = value !== null && typeof plan.price === \"object\" && plan.price !== null ? plan.price.yearly * 12 : null;\n          const label = plan.cta ?? (plan.price === null ? \"Contact sales\" : \"Get started\");\n          const badge = plan.badge ?? (plan.highlighted ? \"Most popular\" : undefined);\n          const buttonStyle = plan.highlighted ? { background: p.primary, color: p.onPrimary } : { background: p.secondary, color: p.text };\n          const buttonClass =\n            \"mt-6 flex h-11 w-full items-center justify-center rounded-xl text-sm font-semibold outline-none transition-[filter,background-color] duration-150 hover:brightness-110 focus-visible:ring-2 active:scale-[0.99]\";\n\n          return (\n            <motion.section\n              key={plan.id}\n              aria-label={`${plan.name} plan`}\n              initial={reduce ? false : { opacity: 0, y: 12 }}\n              animate={{ opacity: 1, y: 0 }}\n              transition={{ duration: 0.4, delay: reduce ? 0 : i * 0.06, ease: [0.22, 1, 0.36, 1] }}\n              className={cn(\"relative flex flex-col rounded-2xl p-6\", plan.highlighted && \"md:-my-2 md:py-8\")}\n              style={{\n                background: plan.highlighted ? p.cardHi : p.card,\n                border: `1px solid ${plan.highlighted ? p.borderHi : p.border}`,\n                boxShadow: plan.highlighted ? (theme === \"dark\" ? \"0 20px 60px -20px rgba(0,0,0,0.8)\" : \"0 20px 50px -24px rgba(10,10,10,0.35)\") : \"none\",\n              }}\n            >\n              <div className=\"flex items-center justify-between gap-2\">\n                <h3 className=\"text-base font-semibold\">{plan.name}</h3>\n                {badge && (\n                  <span className=\"rounded-full px-2.5 py-1 text-[11px] font-semibold\" style={{ background: plan.highlighted ? p.primary : p.secondary, color: plan.highlighted ? p.onPrimary : p.text }}>\n                    {badge}\n                  </span>\n                )}\n              </div>\n              {plan.description && (\n                <p className=\"mt-1.5 min-h-[40px] text-sm leading-5\" style={{ color: p.muted }}>\n                  {plan.description}\n                </p>\n              )}\n\n              <div className=\"mt-5\">\n                <Price value={value} currency={currency} period={period} billing={billing} yearlyTotal={yearlyTotal} p={p} reduce={reduce} />\n              </div>\n\n              {plan.href ? (\n                <a href={plan.href} className={buttonClass} style={buttonStyle}>\n                  {label}\n                </a>\n              ) : (\n                <button type=\"button\" onClick={() => onSelect?.(plan.id, billing)} className={buttonClass} style={buttonStyle}>\n                  {label}\n                </button>\n              )}\n\n              <div className=\"my-6 h-px\" style={{ background: p.border }} />\n\n              <ul className=\"flex flex-col gap-3 text-sm\">\n                {plan.features.map((f) => {\n                  const feature = typeof f === \"string\" ? { label: f, included: true } : { included: true, ...f };\n                  return (\n                    <li key={feature.label} className=\"flex items-start gap-2.5\" style={{ color: feature.included ? p.text : p.faint }}>\n                      <span className=\"mt-0.5 shrink-0\">{feature.included ? <Check color={p.ok} /> : <Cross color={p.faint} />}</span>\n                      <span className={feature.included ? undefined : \"line-through decoration-1\"}>\n                        {feature.label}\n                        {!feature.included && <span className=\"sr-only\"> (not included)</span>}\n                      </span>\n                    </li>\n                  );\n                })}\n              </ul>\n            </motion.section>\n          );\n        })}\n      </div>\n    </div>\n  );\n}\n\nexport default PricingTable;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}