{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "flip-price-cards",
  "title": "Flip Price Cards",
  "description": "Pricing cards that keep the front clean: a big price on one side, and a springy 3D flip on hover or tap to reveal what's included and the call to action.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/flip-price-cards/flip-price-cards.tsx",
      "content": "\"use client\";\n\nimport * as React from \"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 FlipCardsTheme = \"dark\" | \"light\";\n\nexport interface FlipPlan {\n  name: string;\n  tagline: string;\n  monthly: number;\n  yearly: number;\n  features: string[];\n  cta?: string;\n  featured?: boolean;\n}\n\nexport interface FlipPriceCardsProps extends Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"title\" | \"onSelect\"\n> {\n  theme?: FlipCardsTheme;\n  title?: string;\n  plans?: FlipPlan[];\n  currency?: string;\n  /** Height of each card, in px. */\n  cardHeight?: number;\n  /** Flip on hover with a mouse; a click or tap always flips. */\n  flipOnHover?: boolean;\n  onSelect?: (plan: FlipPlan, yearly: boolean) => void;\n}\n\nconst PALETTES = {\n  dark: {\n    face: \"#141416\",\n    back: \"#1B1C20\",\n    border: \"rgba(255,255,255,0.1)\",\n    text: \"#F4F5F7\",\n    sub: \"rgba(255,255,255,0.56)\",\n    faint: \"rgba(255,255,255,0.36)\",\n    chip: \"rgba(255,255,255,0.07)\",\n    accent: \"#87FFE3\",\n    accentText: \"#06241D\",\n    featured: \"linear-gradient(160deg,#233B36 0%,#141416 62%)\",\n    btn: \"#F4F5F7\",\n    btnText: \"#0E0E0E\",\n  },\n  light: {\n    face: \"#FFFFFF\",\n    back: \"#F6F6F4\",\n    border: \"rgba(0,0,0,0.09)\",\n    text: \"#111317\",\n    sub: \"rgba(17,19,23,0.58)\",\n    faint: \"rgba(17,19,23,0.4)\",\n    chip: \"rgba(17,19,23,0.05)\",\n    accent: \"#0E9F80\",\n    accentText: \"#FFFFFF\",\n    featured: \"linear-gradient(160deg,#DDF3EC 0%,#FFFFFF 62%)\",\n    btn: \"#111317\",\n    btnText: \"#FFFFFF\",\n  },\n};\n\nconst DEFAULT_PLANS: FlipPlan[] = [\n  {\n    name: \"Starter\",\n    tagline: \"For side projects\",\n    monthly: 12,\n    yearly: 9,\n    features: [\n      \"3 projects\",\n      \"10 GB storage\",\n      \"Community support\",\n      \"Basic analytics\",\n    ],\n    cta: \"Start free trial\",\n  },\n  {\n    name: \"Studio\",\n    tagline: \"For growing teams\",\n    monthly: 39,\n    yearly: 31,\n    features: [\n      \"Unlimited projects\",\n      \"200 GB storage\",\n      \"Priority support\",\n      \"Advanced analytics\",\n      \"Custom domains\",\n    ],\n    cta: \"Start free trial\",\n    featured: true,\n  },\n  {\n    name: \"Scale\",\n    tagline: \"For whole companies\",\n    monthly: 99,\n    yearly: 79,\n    features: [\n      \"Everything in Studio\",\n      \"2 TB storage\",\n      \"SSO and audit log\",\n      \"Dedicated manager\",\n    ],\n    cta: \"Talk to sales\",\n  },\n];\n\nfunction FlipIcon() {\n  return (\n    <svg\n      width=\"13\"\n      height=\"13\"\n      viewBox=\"0 0 16 16\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"1.6\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      aria-hidden=\"true\"\n    >\n      <path d=\"M2.5 8a5.5 5.5 0 0 1 9.4-3.9L13.5 6M13.5 2.5V6H10M13.5 8a5.5 5.5 0 0 1-9.4 3.9L2.5 10M2.5 13.5V10H6\" />\n    </svg>\n  );\n}\n\nfunction Card({\n  plan,\n  yearly,\n  currency,\n  height,\n  flipOnHover,\n  pal,\n  onSelect,\n}: {\n  plan: FlipPlan;\n  yearly: boolean;\n  currency: string;\n  height: number;\n  flipOnHover: boolean;\n  pal: (typeof PALETTES)[\"dark\"];\n  onSelect?: FlipPriceCardsProps[\"onSelect\"];\n}) {\n  const [pinned, setPinned] = React.useState(false);\n  const [hover, setHover] = React.useState(false);\n  const flipped = pinned || (flipOnHover && hover);\n  const price = yearly ? plan.yearly : plan.monthly;\n  // backface-visibility hides the far side where 3D works; the opacity swap at mid-turn covers engines where it doesn't.\n  const faceClass =\n    \"absolute inset-0 flex flex-col rounded-[20px] p-6 [-webkit-backface-visibility:hidden] [backface-visibility:hidden] transition-opacity delay-150 duration-0 motion-reduce:delay-0\";\n\n  return (\n    <div\n      className=\"[perspective:1400px]\"\n      style={{ height }}\n      onPointerEnter={(e) => e.pointerType === \"mouse\" && setHover(true)}\n      onPointerLeave={(e) => e.pointerType === \"mouse\" && setHover(false)}\n    >\n      <div\n        className=\"relative size-full [transform-style:preserve-3d] motion-safe:transition-transform motion-safe:duration-700 motion-safe:ease-[cubic-bezier(0.3,1.25,0.4,1)]\"\n        style={{ transform: flipped ? \"rotateY(180deg)\" : \"none\" }}\n      >\n        <div\n          className={faceClass}\n          inert={flipped}\n          style={{\n            opacity: flipped ? 0 : 1,\n            background: plan.featured ? pal.featured : pal.face,\n            boxShadow: `inset 0 0 0 1px ${plan.featured ? pal.accent : pal.border}`,\n          }}\n        >\n          <div className=\"flex items-center justify-between gap-2\">\n            <p className=\"m-0 text-[15px] font-semibold\">{plan.name}</p>\n            {plan.featured && (\n              <span\n                className=\"rounded-full px-2 py-0.5 text-[10.5px] font-semibold\"\n                style={{ background: pal.accent, color: pal.accentText }}\n              >\n                Popular\n              </span>\n            )}\n          </div>\n          <p className=\"m-0 mt-1 text-[12.5px]\" style={{ color: pal.sub }}>\n            {plan.tagline}\n          </p>\n          <p className=\"m-0 mt-auto flex items-baseline gap-1\">\n            <span className=\"text-[56px] leading-none font-semibold tracking-[-0.045em] tabular-nums\">\n              {currency}\n              {price}\n            </span>\n            <span className=\"text-[13px]\" style={{ color: pal.sub }}>\n              / mo\n            </span>\n          </p>\n          <p\n            className=\"m-0 mt-1.5 min-h-[18px] text-[12px]\"\n            style={{ color: pal.faint }}\n          >\n            {yearly\n              ? `${currency}${plan.yearly * 12} billed yearly`\n              : \"Billed monthly\"}\n          </p>\n          <button\n            type=\"button\"\n            onClick={() => setPinned(true)}\n            className=\"mt-auto flex cursor-pointer items-center justify-center gap-1.5 rounded-xl py-2.5 text-[13px] font-medium\"\n            style={{ background: pal.chip }}\n          >\n            <FlipIcon />\n            What&apos;s included\n          </button>\n        </div>\n        <div\n          className={faceClass}\n          inert={!flipped}\n          style={{\n            opacity: flipped ? 1 : 0,\n            background: pal.back,\n            boxShadow: `inset 0 0 0 1px ${pal.border}`,\n            transform: \"rotateY(180deg)\",\n          }}\n        >\n          <div className=\"flex items-center justify-between gap-2\">\n            <p className=\"m-0 text-[15px] font-semibold\">{plan.name}</p>\n            <button\n              type=\"button\"\n              aria-label={`Back to ${plan.name} price`}\n              onClick={() => {\n                setPinned(false);\n                setHover(false);\n              }}\n              className=\"grid size-7 cursor-pointer place-items-center rounded-lg\"\n              style={{ background: pal.chip, color: pal.sub }}\n            >\n              <FlipIcon />\n            </button>\n          </div>\n          <ul className=\"m-0 mt-4 flex list-none flex-col gap-2.5 p-0 text-[13.5px]\">\n            {plan.features.map((f) => (\n              <li key={f} className=\"flex items-start gap-2\">\n                <svg\n                  width=\"15\"\n                  height=\"15\"\n                  viewBox=\"0 0 16 16\"\n                  fill=\"none\"\n                  stroke={pal.accent}\n                  strokeWidth=\"2\"\n                  strokeLinecap=\"round\"\n                  strokeLinejoin=\"round\"\n                  aria-hidden=\"true\"\n                  className=\"mt-[2px] shrink-0\"\n                >\n                  <path d=\"M3.2 8.4 6.5 11.6 12.8 4.6\" />\n                </svg>\n                {f}\n              </li>\n            ))}\n          </ul>\n          <button\n            type=\"button\"\n            onClick={() => onSelect?.(plan, yearly)}\n            className=\"mt-auto cursor-pointer rounded-xl py-2.5 text-[13px] font-semibold transition-opacity hover:opacity-90\"\n            style={{ background: pal.btn, color: pal.btnText }}\n          >\n            {plan.cta ?? \"Choose plan\"}\n          </button>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport function FlipPriceCards({\n  theme = \"dark\",\n  title = \"Simple plans, nothing hidden\",\n  plans = DEFAULT_PLANS,\n  currency = \"$\",\n  cardHeight = 340,\n  flipOnHover = true,\n  onSelect,\n  className,\n  style,\n  ...props\n}: FlipPriceCardsProps) {\n  const pal = PALETTES[theme];\n  const [yearly, setYearly] = React.useState(true);\n  const best = Math.max(\n    ...plans.map((p) => Math.round((1 - p.yearly / p.monthly) * 100)),\n  );\n\n  return (\n    <div\n      className={cn(\"@container w-full\", className)}\n      style={{\n        color: pal.text,\n        fontFamily: \"Inter, -apple-system, BlinkMacSystemFont, sans-serif\",\n        ...style,\n      }}\n      {...props}\n    >\n      <div className=\"flex flex-wrap items-center justify-between gap-3\">\n        <h3 className=\"m-0 text-[22px] font-semibold tracking-[-0.02em]\">\n          {title}\n        </h3>\n        <div\n          role=\"radiogroup\"\n          aria-label=\"Billing\"\n          className=\"flex rounded-full p-0.5 text-[12px] font-medium\"\n          style={{ background: pal.chip }}\n        >\n          {[false, true].map((y) => (\n            <button\n              key={String(y)}\n              type=\"button\"\n              role=\"radio\"\n              aria-checked={yearly === y}\n              onClick={() => setYearly(y)}\n              className=\"cursor-pointer rounded-full px-3 py-1 transition-colors\"\n              style={{\n                background: yearly === y ? pal.face : \"transparent\",\n                color: yearly === y ? pal.text : pal.sub,\n                boxShadow: yearly === y ? \"0 1px 2px rgba(0,0,0,.2)\" : \"none\",\n              }}\n            >\n              {y ? `Yearly −${best}%` : \"Monthly\"}\n            </button>\n          ))}\n        </div>\n      </div>\n      <div className=\"mt-5 grid gap-4 @[640px]:grid-cols-3\">\n        {plans.map((p) => (\n          <Card\n            key={p.name}\n            plan={p}\n            yearly={yearly}\n            currency={currency}\n            height={cardHeight}\n            flipOnHover={flipOnHover}\n            pal={pal}\n            onSelect={onSelect}\n          />\n        ))}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}