{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"pricing-comparison","type":"registry:block","title":"Pricing comparison","description":"Plans compared feature by feature in groups, with hints, the popular column tinted, and actions in the header.","dependencies":["lucide-react"],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/button.json","https://dashral.com/r/scroll-shadow.json","https://dashral.com/r/tooltip.json"],"files":[{"path":"registry/dashral/blocks/pricing-comparison.tsx","type":"registry:file","target":"components/dashral/blocks/pricing-comparison.tsx","content":"import { Check, Info, Minus } from \"lucide-react\"\nimport { Button } from \"../button\"\nimport { ScrollShadow } from \"../scroll-shadow\"\nimport { Tooltip } from \"../tooltip\"\nimport { cn } from \"../lib/utils\"\n\n/** A plan's column: its name, its price a month as shown, and its button (a link, or onSelect without one). */\nexport type ComparePlan = { name: string; price: string; popular?: boolean; cta: string; href?: string }\n/** Included (true), not (false), or what it comes with (\"20\"). */\nexport type CompareValue = boolean | string\n/** A group of rows; each row has one value per plan, in the plans' order. */\nexport type CompareGroup = { title: string; rows: { feature: string; hint?: string; values: CompareValue[] }[] }\n\nconst samplePlans: ComparePlan[] = [\n  { name: \"Starter\", price: \"$0\", cta: \"Start free\", href: \"#\" },\n  { name: \"Team\", price: \"$29\", popular: true, cta: \"Start trial\", href: \"#\" },\n  { name: \"Business\", price: \"$79\", cta: \"Talk to sales\", href: \"#\" },\n]\n\ntype Value = CompareValue\nconst sampleGroups: CompareGroup[] = [\n  {\n    title: \"Dashboards\",\n    rows: [\n      { feature: \"Dashboards\", values: [\"1\", \"Unlimited\", \"Unlimited\"] },\n      { feature: \"Data sources\", values: [\"3\", \"20\", \"Unlimited\"] },\n      { feature: \"History\", hint: \"How far back your charts can go.\", values: [\"7 days\", \"1 year\", \"Unlimited\"] },\n      { feature: \"Scheduled reports\", values: [false, true, true] },\n    ],\n  },\n  {\n    title: \"Team\",\n    rows: [\n      { feature: \"Members\", values: [\"1\", \"Up to 25\", \"Unlimited\"] },\n      { feature: \"Roles and permissions\", values: [false, true, true] },\n      { feature: \"Single sign-on (SSO)\", hint: \"Sign in with Okta, Azure AD or Google Workspace.\", values: [false, false, true] },\n      { feature: \"Audit log\", values: [false, false, true] },\n    ],\n  },\n  {\n    title: \"Support\",\n    rows: [\n      { feature: \"Community\", values: [true, true, true] },\n      { feature: \"Email support\", values: [false, true, true] },\n      { feature: \"Account manager\", values: [false, false, true] },\n    ],\n  },\n]\n\nfunction Cell({ value }: { value: Value }) {\n  if (value === true) return <Check className=\"mx-auto size-4 text-primary-text\" aria-label=\"Included\" />\n  if (value === false) return <Minus className=\"mx-auto size-4 text-muted-foreground/50\" aria-label=\"Not included\" />\n  return <span className=\"text-sm\">{value}</span>\n}\n\n/**\n * Plans compared feature by feature: a header row with each plan's price and action, groups of rows, a hint on the\n * features that need one, and the popular plan's column tinted. Scrolls sideways on phones, the feature names\n * staying in place. Every part comes from props.\n */\nexport function PricingComparison({\n  eyebrow = \"Compare plans\",\n  title = \"Everything in each plan\",\n  plans = samplePlans,\n  groups = sampleGroups,\n  per = \"/ month\",\n  onSelect,\n}: {\n  eyebrow?: React.ReactNode\n  title?: React.ReactNode\n  plans?: ComparePlan[]\n  groups?: CompareGroup[]\n  /** After each price. */\n  per?: string\n  onSelect?: (plan: ComparePlan) => void\n}) {\n  return (\n    <section className=\"bg-background px-4 py-16 sm:px-6 sm:py-24\">\n      <div className=\"mx-auto max-w-6xl\">\n        <div className=\"max-w-2xl\">\n          {eyebrow && <p className=\"text-sm font-medium text-primary-text\">{eyebrow}</p>}\n          <h2 className=\"mt-3 text-3xl font-semibold tracking-[-0.03em] text-balance sm:text-4xl\">{title}</h2>\n        </div>\n\n        <ScrollShadow orientation=\"horizontal\" fade=\"end\" className=\"mt-10\">\n          {/* Fixed layout: the plan columns share the width equally. */}\n          <table className=\"w-full min-w-[40rem] table-fixed border-separate border-spacing-0 text-start\">\n            <caption className=\"sr-only\">Features by plan</caption>\n            <thead>\n              <tr>\n                <th scope=\"col\" className=\"sticky start-0 z-10 w-1/3 bg-background pb-6 text-start align-bottom text-sm font-medium text-muted-foreground\">\n                  Features\n                </th>\n                {plans.map((plan) => (\n                  <th key={plan.name} scope=\"col\" className={cn(\"px-2 pb-6 text-center align-bottom sm:px-4\", plan.popular && \"rounded-t-xl bg-primary/5 pt-4\")}>\n                    <span className=\"block text-base font-semibold\">{plan.name}</span>\n                    <span className=\"mt-1 block text-sm font-normal text-muted-foreground\">\n                      <span className=\"text-2xl font-semibold text-foreground\">{plan.price}</span> {per}\n                    </span>\n                    {plan.href ? (\n                      <Button size=\"sm\" variant={plan.popular ? \"solid\" : \"outline\"} className=\"mt-4 h-auto min-h-8 w-full py-1.5 leading-snug text-balance whitespace-normal\" asChild>\n                        <a href={plan.href}>{plan.cta}</a>\n                      </Button>\n                    ) : (\n                      <Button size=\"sm\" variant={plan.popular ? \"solid\" : \"outline\"} className=\"mt-4 h-auto min-h-8 w-full py-1.5 leading-snug text-balance whitespace-normal\" onClick={() => onSelect?.(plan)}>\n                        {plan.cta}\n                      </Button>\n                    )}\n                  </th>\n                ))}\n              </tr>\n            </thead>\n            {groups.map((group) => (\n              <tbody key={group.title}>\n                <tr>\n                  <th scope=\"colgroup\" className=\"sticky start-0 z-10 bg-background pt-8 pb-3 text-start text-sm font-semibold\">\n                    {group.title}\n                  </th>\n                  {/* Empty cells, so the popular plan's tint runs unbroken through the group titles. */}\n                  {plans.map((plan) => (\n                    <td key={plan.name} aria-hidden className={cn(plan.popular && \"bg-primary/5\")} />\n                  ))}\n                </tr>\n                {group.rows.map((row) => (\n                  <tr key={row.feature}>\n                    <th scope=\"row\" className=\"sticky start-0 z-10 border-t bg-background py-3 pe-4 text-start text-sm font-normal\">\n                      <span className=\"inline-flex items-center gap-1.5\">\n                        {row.feature}\n                        {row.hint && (\n                          <Tooltip content={row.hint}>\n                            <button type=\"button\" aria-label={`About ${row.feature}`} className=\"rounded-full text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50\">\n                              <Info className=\"size-3.5\" />\n                            </button>\n                          </Tooltip>\n                        )}\n                      </span>\n                    </th>\n                    {row.values.map((value, i) => (\n                      <td key={i} className={cn(\"border-t px-4 py-3 text-center\", plans[i]!.popular && \"bg-primary/5 [tbody:last-of-type_tr:last-child_&]:rounded-b-xl\")}>\n                        <Cell value={value} />\n                      </td>\n                    ))}\n                  </tr>\n                ))}\n              </tbody>\n            ))}\n          </table>\n        </ScrollShadow>\n      </div>\n    </section>\n  )\n}\n"}],"cssVars":{"theme":{"color-primary-text":"var(--primary-text, var(--primary))"},"light":{},"dark":{}}}