{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pricing-matrix-sticky",
  "type": "registry:component",
  "title": "Pricing Matrix Sticky",
  "description": "A full feature matrix in its own scroller whose plan header sticks and compacts as you scroll. Columns light up under the pointer and an Only show differences switch folds away rows every plan shares.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "pricing",
    "pricing",
    "comparison",
    "matrix",
    "sticky header",
    "table",
    "filter"
  ],
  "docs": "https://hyperblur.dev/effects/pricing-matrix-sticky",
  "files": [
    {
      "path": "registry/hyperblur/pricing-matrix-sticky.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pricing-matrix-sticky.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type PricingMatrixValue = boolean | string;\n\nexport interface PricingMatrixPlan {\n  name: string;\n  price: number | null;\n  note: string;\n  cta: { label: string; href: string };\n  highlight?: boolean;\n}\n\nexport interface PricingMatrixGroup {\n  label: string;\n  rows: { label: string; values: PricingMatrixValue[] }[];\n}\n\nexport interface PricingMatrixStickyProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  title?: string;\n  subtitle?: string;\n  plans?: PricingMatrixPlan[];\n  groups?: PricingMatrixGroup[];\n  currency?: string;\n  locale?: string;\n  customLabel?: string;\n  maxHeight?: number;\n  diffOnly?: boolean;\n  defaultDiffOnly?: boolean;\n  onDiffOnlyChange?: (value: boolean) => void;\n  diffLabel?: string;\n  accent?: string;\n}\n\nconst defaultPlans: PricingMatrixPlan[] = [\n  { name: \"Free\", price: 0, note: \"forever\", cta: { label: \"Sign up\", href: \"#\" } },\n  { name: \"Plus\", price: 10, note: \"per seat / mo\", cta: { label: \"Try Plus\", href: \"#\" } },\n  { name: \"Business\", price: 22, note: \"per seat / mo\", cta: { label: \"Try Business\", href: \"#\" }, highlight: true },\n  { name: \"Enterprise\", price: null, note: \"billed yearly\", cta: { label: \"Contact sales\", href: \"#\" } },\n];\n\nconst defaultGroups: PricingMatrixGroup[] = [\n  {\n    label: \"Workspace\",\n    rows: [\n      { label: \"Members\", values: [\"Up to 3\", \"Up to 50\", \"Unlimited\", \"Unlimited\"] },\n      { label: \"Pages and docs\", values: [\"Unlimited\", \"Unlimited\", \"Unlimited\", \"Unlimited\"] },\n      { label: \"File uploads\", values: [\"5 MB\", \"Unlimited\", \"Unlimited\", \"Unlimited\"] },\n      { label: \"Page history\", values: [\"7 days\", \"30 days\", \"90 days\", \"Unlimited\"] },\n      { label: \"Guests\", values: [\"10\", \"100\", \"250\", \"Custom\"] },\n    ],\n  },\n  {\n    label: \"Collaboration\",\n    rows: [\n      { label: \"Real-time editing\", values: [true, true, true, true] },\n      { label: \"Comments and mentions\", values: [true, true, true, true] },\n      { label: \"Private teamspaces\", values: [false, false, true, true] },\n      { label: \"Bulk PDF export\", values: [false, false, true, true] },\n    ],\n  },\n  {\n    label: \"Security\",\n    rows: [\n      { label: \"Two-factor authentication\", values: [true, true, true, true] },\n      { label: \"SAML single sign-on\", values: [false, false, true, true] },\n      { label: \"SCIM user provisioning\", values: [false, false, false, true] },\n      { label: \"Audit log\", values: [false, false, false, true] },\n      { label: \"Data retention policies\", values: [false, false, false, true] },\n    ],\n  },\n  {\n    label: \"Support\",\n    rows: [\n      { label: \"Help center\", values: [true, true, true, true] },\n      { label: \"Priority support\", values: [false, false, true, true] },\n      { label: \"Dedicated success manager\", values: [false, false, false, true] },\n    ],\n  },\n];\n\nconst css = `\n.hb-vh4 {\n  --hb-vh4-accent: #2f7bff;\n  --hb-vh4-p: 0;\n  container-type: inline-size;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-vh4 *, .hb-vh4 *::before, .hb-vh4 *::after { box-sizing: border-box; }\n.hb-vh4-inner { max-width: 1080px; margin: 0 auto; padding: 56px 20px 64px; }\n.hb-vh4-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }\n.hb-vh4-title { margin: 0; font-size: clamp(26px, 4cqi, 38px); font-weight: 650; letter-spacing: -.03em; line-height: 1.1; }\n.hb-vh4-sub { margin: 8px 0 0; color: #8f8f8f; font-size: 15px; line-height: 1.55; max-width: 480px; }\n.hb-vh4-diff { display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; color: #a1a1a1; font: inherit; font-size: 13.5px; cursor: pointer; }\n.hb-vh4-diff-box { position: relative; width: 34px; height: 20px; border-radius: 999px; background: #232326; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); transition: background-color .3s ease; }\n.hb-vh4-diff-box::after { content: \"\"; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #d4d4d8; transition: transform .4s cubic-bezier(.34, 1.56, .64, 1); }\n.hb-vh4-diff[aria-checked=\"true\"] { color: #ededed; }\n.hb-vh4-diff[aria-checked=\"true\"] .hb-vh4-diff-box { background: var(--hb-vh4-accent); }\n.hb-vh4-diff[aria-checked=\"true\"] .hb-vh4-diff-box::after { transform: translateX(14px); background: #fff; }\n.hb-vh4-diff:focus-visible { outline: none; }\n.hb-vh4-diff:focus-visible .hb-vh4-diff-box { outline: 2px solid var(--hb-vh4-accent); outline-offset: 2px; }\n.hb-vh4-scroll {\n  position: relative;\n  margin-top: 28px;\n  border: 1px solid rgba(255, 255, 255, .08);\n  border-radius: 20px;\n  background: #0d0d0f;\n  overflow: auto;\n  overscroll-behavior: contain;\n  scrollbar-width: thin;\n  scrollbar-color: #2a2a2e transparent;\n}\n.hb-vh4-table { min-width: 680px; }\n.hb-vh4-row { display: grid; grid-template-columns: minmax(170px, 1.35fr) repeat(var(--n), minmax(110px, 1fr)); }\n.hb-vh4-head {\n  position: sticky;\n  top: 0;\n  z-index: 3;\n  background: color-mix(in srgb, #0d0d0f 88%, transparent);\n  -webkit-backdrop-filter: blur(14px) saturate(140%);\n  backdrop-filter: blur(14px) saturate(140%);\n  border-bottom: 1px solid rgba(255, 255, 255, calc(.04 + var(--hb-vh4-p) * .06));\n  box-shadow: 0 calc(var(--hb-vh4-p) * 18px) 30px -18px rgba(0, 0, 0, calc(var(--hb-vh4-p) * .9));\n}\n.hb-vh4-corner { display: flex; align-items: flex-end; padding: 16px 18px; color: #6f6f6f; font-size: 12px; }\n.hb-vh4-plan { position: relative; display: flex; flex-direction: column; padding: calc(22px - var(--hb-vh4-p) * 10px) 14px calc(18px - var(--hb-vh4-p) * 6px); }\n.hb-vh4-pname { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }\n.hb-vh4-pname i { width: 6px; height: 6px; border-radius: 999px; background: var(--hb-vh4-accent); font-style: normal; box-shadow: 0 0 8px var(--hb-vh4-accent); }\n.hb-vh4-pprice { display: flex; align-items: baseline; gap: 5px; margin-top: calc(10px - var(--hb-vh4-p) * 8px); }\n.hb-vh4-pprice strong { font-size: calc(30px - var(--hb-vh4-p) * 12px); font-weight: 650; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }\n.hb-vh4-pprice span { color: #8f8f8f; font-size: 12px; white-space: nowrap; }\n.hb-vh4-pcta {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  height: calc(34px - var(--hb-vh4-p) * 6px);\n  margin-top: calc(14px - var(--hb-vh4-p) * 6px);\n  border-radius: 9px;\n  border: 1px solid rgba(255, 255, 255, .12);\n  background: rgba(255, 255, 255, .03);\n  color: #ededed;\n  font-size: 12.5px;\n  font-weight: 600;\n  text-decoration: none;\n  white-space: nowrap;\n  transition: background-color .2s ease, border-color .2s ease;\n}\n.hb-vh4-pcta:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .2); }\n.hb-vh4-pcta:focus-visible { outline: 2px solid var(--hb-vh4-accent); outline-offset: 2px; }\n.hb-vh4-plan[data-hl=\"true\"] .hb-vh4-pcta { border-color: transparent; background: var(--hb-vh4-accent); color: #fff; }\n.hb-vh4-col { position: relative; }\n.hb-vh4-col[data-hl=\"true\"] { background: color-mix(in srgb, var(--hb-vh4-accent) 6%, transparent); }\n.hb-vh4-col[data-hover=\"true\"] { background: rgba(255, 255, 255, .035); }\n.hb-vh4-col[data-hl=\"true\"][data-hover=\"true\"] { background: color-mix(in srgb, var(--hb-vh4-accent) 10%, transparent); }\n.hb-vh4-plan[data-hl=\"true\"]::before { content: \"\"; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--hb-vh4-accent); box-shadow: 0 0 14px var(--hb-vh4-accent); }\n.hb-vh4-group { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .45s cubic-bezier(.2, .8, .2, 1), opacity .3s ease; }\n.hb-vh4-group[data-hidden=\"true\"] { grid-template-rows: 0fr; opacity: 0; }\n.hb-vh4-group > div { overflow: hidden; min-height: 0; }\n.hb-vh4-glabel { padding: 22px 18px 8px; color: #6f6f6f; font-family: var(--font-mono), ui-monospace, monospace; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; }\n.hb-vh4-line { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .4s cubic-bezier(.2, .8, .2, 1), opacity .25s ease; }\n.hb-vh4-line[data-hidden=\"true\"] { grid-template-rows: 0fr; opacity: 0; }\n.hb-vh4-line > .hb-vh4-row { overflow: hidden; min-height: 0; }\n.hb-vh4-line:hover .hb-vh4-cell, .hb-vh4-line:hover .hb-vh4-label { background-color: rgba(255, 255, 255, .02); }\n.hb-vh4-label, .hb-vh4-cell { display: flex; align-items: center; min-height: 0; border-top: 1px solid rgba(255, 255, 255, .05); font-size: 13.5px; }\n.hb-vh4-label { padding: 13px 18px; color: #b5b5b5; }\n.hb-vh4-cell { justify-content: flex-start; padding: 13px 14px; color: #ededed; font-variant-numeric: tabular-nums; }\n.hb-vh4-cell svg { width: 16px; height: 16px; }\n.hb-vh4-yes { color: var(--hb-vh4-accent); }\n.hb-vh4-no { color: #3f3f46; }\n.hb-vh4-empty { padding: 36px 18px; color: #6f6f6f; font-size: 13.5px; text-align: center; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-vh4 *, .hb-vh4 *::before, .hb-vh4 *::after { transition: none !important; }\n}\n`;\n\nconst yes = (\n  <svg viewBox=\"0 0 16 16\" className=\"hb-vh4-yes\" role=\"img\" aria-label=\"Included\">\n    <path d=\"M3.5 8.5l3 3 6-7\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n  </svg>\n);\nconst no = (\n  <svg viewBox=\"0 0 16 16\" className=\"hb-vh4-no\" role=\"img\" aria-label=\"Not included\">\n    <path d=\"M4.5 8h7\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n  </svg>\n);\n\nexport function PricingMatrixSticky({\n  title = \"Compare every feature\",\n  subtitle = \"All the details in one place. Scroll the table and the plan headers stay with you.\",\n  plans = defaultPlans,\n  groups = defaultGroups,\n  currency = \"USD\",\n  locale = \"en-US\",\n  customLabel = \"Custom\",\n  maxHeight = 560,\n  diffOnly,\n  defaultDiffOnly = false,\n  onDiffOnlyChange,\n  diffLabel = \"Only show differences\",\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: PricingMatrixStickyProps) {\n  const [innerDiff, setInnerDiff] = React.useState(defaultDiffOnly);\n  const [hover, setHover] = React.useState<number | null>(null);\n  const scrollRef = React.useRef<HTMLDivElement>(null);\n  const rootRef = React.useRef<HTMLElement>(null);\n  const diff = diffOnly ?? innerDiff;\n\n  const money = React.useMemo(\n    () => new Intl.NumberFormat(locale, { style: \"currency\", currency, maximumFractionDigits: 0 }),\n    [locale, currency],\n  );\n\n  const onScroll = () => {\n    const el = scrollRef.current;\n    const root = rootRef.current;\n    if (!el || !root) return;\n    const p = Math.min(1, el.scrollTop / 90);\n    root.style.setProperty(\"--hb-vh4-p\", p.toFixed(3));\n  };\n\n  const toggleDiff = () => {\n    const next = !diff;\n    if (diffOnly === undefined) setInnerDiff(next);\n    onDiffOnlyChange?.(next);\n  };\n\n  const same = (values: PricingMatrixValue[]) => values.every((v) => v === values[0]);\n  const n = plans.length;\n  const visibleCount = groups.reduce((s, g) => s + g.rows.filter((r) => !diff || !same(r.values)).length, 0);\n\n  return (\n    <section\n      ref={rootRef}\n      className={`hb-vh4 ${className}`}\n      style={{ \"--hb-vh4-accent\": accent, \"--n\": n, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-pricing-matrix-sticky\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vh4-inner\">\n        <div className=\"hb-vh4-bar\">\n          <div>\n            <h2 className=\"hb-vh4-title\">{title}</h2>\n            {subtitle ? <p className=\"hb-vh4-sub\">{subtitle}</p> : null}\n          </div>\n          <button type=\"button\" role=\"switch\" aria-checked={diff} className=\"hb-vh4-diff\" onClick={toggleDiff}>\n            <span className=\"hb-vh4-diff-box\" aria-hidden=\"true\" />\n            {diffLabel}\n          </button>\n        </div>\n        <div\n          ref={scrollRef}\n          className=\"hb-vh4-scroll\"\n          style={{ maxHeight }}\n          onScroll={onScroll}\n          onPointerLeave={() => setHover(null)}\n          tabIndex={0}\n          role=\"region\"\n          aria-label={title}\n        >\n          <div className=\"hb-vh4-table\" role=\"table\" aria-label={title}>\n            <div className=\"hb-vh4-head\" role=\"rowgroup\">\n              <div className=\"hb-vh4-row\" role=\"row\">\n                <div className=\"hb-vh4-corner\" role=\"columnheader\">{visibleCount} features</div>\n                {plans.map((p, i) => (\n                  <div\n                    key={p.name}\n                    role=\"columnheader\"\n                    className=\"hb-vh4-plan hb-vh4-col\"\n                    data-hl={p.highlight ? \"true\" : undefined}\n                    data-hover={hover === i ? \"true\" : undefined}\n                    onPointerEnter={() => setHover(i)}\n                  >\n                    <span className=\"hb-vh4-pname\">{p.highlight ? <i aria-hidden=\"true\" /> : null}{p.name}</span>\n                    <span className=\"hb-vh4-pprice\">\n                      <strong>{p.price === null ? customLabel : money.format(p.price)}</strong>\n                      <span>{p.note}</span>\n                    </span>\n                    <a className=\"hb-vh4-pcta\" href={p.cta.href}>{p.cta.label}</a>\n                  </div>\n                ))}\n              </div>\n            </div>\n            <div role=\"rowgroup\">\n              {groups.map((g) => {\n                const hiddenGroup = diff && g.rows.every((r) => same(r.values));\n                return (\n                  <div key={g.label} className=\"hb-vh4-group\" data-hidden={hiddenGroup ? \"true\" : undefined}>\n                    <div>\n                      <div className=\"hb-vh4-glabel\" role=\"row\">\n                        <span role=\"rowheader\">{g.label}</span>\n                      </div>\n                      {g.rows.map((r) => {\n                        const hidden = diff && same(r.values);\n                        return (\n                          <div key={r.label} className=\"hb-vh4-line\" data-hidden={hidden ? \"true\" : undefined} aria-hidden={hidden || undefined}>\n                            <div className=\"hb-vh4-row\" role=\"row\">\n                              <div className=\"hb-vh4-label\" role=\"rowheader\">{r.label}</div>\n                              {r.values.map((v, i) => (\n                                <div\n                                  key={i}\n                                  role=\"cell\"\n                                  className=\"hb-vh4-cell hb-vh4-col\"\n                                  data-hl={plans[i]?.highlight ? \"true\" : undefined}\n                                  data-hover={hover === i ? \"true\" : undefined}\n                                  onPointerEnter={() => setHover(i)}\n                                >\n                                  {v === true ? yes : v === false ? no : v}\n                                </div>\n                              ))}\n                            </div>\n                          </div>\n                        );\n                      })}\n                    </div>\n                  </div>\n                );\n              })}\n              {visibleCount === 0 ? <div className=\"hb-vh4-empty\">Every plan includes the same features.</div> : null}\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}