{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"pricing-tiers","type":"registry:block","title":"Pricing tiers","description":"Three plans with a monthly/yearly switch and the saving, the popular plan raised, and what each includes.","dependencies":["lucide-react"],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/lib-motion.json","https://dashral.com/r/badge.json","https://dashral.com/r/button.json","https://dashral.com/r/segmented-control.json"],"files":[{"path":"registry/dashral/blocks/pricing-tiers.tsx","type":"registry:file","target":"components/dashral/blocks/pricing-tiers.tsx","content":"\"use client\"\n\nimport { useState } from \"react\"\nimport { Check } from \"lucide-react\"\nimport { Badge } from \"../badge\"\nimport { Button } from \"../button\"\nimport { SegmentedControl } from \"../segmented-control\"\nimport { useCountTo } from \"../lib/motion\"\nimport { cn } from \"../lib/utils\"\n\nexport type Billing = \"monthly\" | \"yearly\"\n/** A plan: its prices a month (yearly is the monthly price when billed yearly), its button and what it includes. */\nexport type TierPlan = {\n  name: string\n  blurb: string\n  price: { monthly: number; yearly: number }\n  cta: string\n  /** Where the button goes; without it, onSelect hears the pick. */\n  href?: string\n  popular?: boolean\n  features: string[]\n}\n\nconst samplePlans: TierPlan[] = [\n  {\n    name: \"Starter\",\n    blurb: \"For one person finding their numbers.\",\n    price: { monthly: 0, yearly: 0 },\n    cta: \"Start for free\",\n    features: [\"1 dashboard\", \"3 data sources\", \"7 days of history\", \"Community support\"],\n  },\n  {\n    name: \"Team\",\n    blurb: \"For teams that meet around the same charts.\",\n    price: { monthly: 29, yearly: 23 },\n    cta: \"Start a 14-day trial\",\n    popular: true,\n    features: [\"Unlimited dashboards\", \"20 data sources\", \"1 year of history\", \"Roles and sign-in with Google\", \"Email support\"],\n  },\n  {\n    name: \"Business\",\n    blurb: \"For companies with their own rules.\",\n    price: { monthly: 79, yearly: 63 },\n    cta: \"Talk to sales\",\n    features: [\"Everything in Team\", \"Unlimited data sources\", \"Unlimited history\", \"SSO and an audit log\", \"A named account manager\"],\n  },\n]\n\n/** A plan's price, counting to the new amount when the billing changes. */\nfunction Price({ value, money }: { value: number; money: (n: number) => string }) {\n  return money(useCountTo(value))\n}\n\n/**\n * Plans side by side: a monthly/yearly switch that shows the saving, the popular plan raised and marked, what each\n * includes, and its action. The prices ease to their new value when the billing changes. Stacks on phones. Every part\n * comes from props.\n */\nexport function PricingTiers({\n  eyebrow = \"Pricing\",\n  title = \"Simple plans that grow with you\",\n  description = \"Start free. Upgrade when your team does. Cancel any time.\",\n  plans = samplePlans,\n  saving = \"Save 20%\",\n  defaultBilling = \"yearly\",\n  currency = \"USD\",\n  locale = \"en-US\",\n  onSelect,\n}: {\n  eyebrow?: React.ReactNode\n  title?: React.ReactNode\n  description?: React.ReactNode\n  plans?: TierPlan[]\n  /** The badge beside the billing switch; none hides it. */\n  saving?: string\n  defaultBilling?: Billing\n  currency?: string\n  locale?: string\n  /** A plan's button without an href: the plan and the billing picked. */\n  onSelect?: (plan: TierPlan, billing: Billing) => void\n}) {\n  const [billing, setBilling] = useState<Billing>(defaultBilling)\n  const money = (n: number) => new Intl.NumberFormat(locale, { style: \"currency\", currency, maximumFractionDigits: Number.isInteger(n) ? 0 : 2 }).format(n)\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=\"mx-auto max-w-2xl text-center\">\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          {description && <p className=\"mt-4 text-pretty text-muted-foreground\">{description}</p>}\n          <div className=\"mt-8 flex items-center justify-center gap-3\">\n            <SegmentedControl\n              aria-label=\"Billing\"\n              value={billing}\n              onValueChange={(v) => setBilling(v as Billing)}\n              options={[\n                { value: \"monthly\", label: \"Monthly\" },\n                { value: \"yearly\", label: \"Yearly\" },\n              ]}\n            />\n            {saving && (\n              <Badge variant=\"soft\" color=\"success\">\n                {saving}\n              </Badge>\n            )}\n          </div>\n        </div>\n\n        <div className=\"mt-12 grid items-start gap-6 lg:grid-cols-[repeat(var(--count),minmax(0,1fr))]\" style={{ \"--count\": plans.length } as React.CSSProperties}>\n          {plans.map((plan) => {\n            const price = plan.price[billing]\n            return (\n              <div\n                key={plan.name}\n                className={cn(\n                  \"relative grid gap-6 rounded-2xl border bg-card p-6 sm:p-8\",\n                  plan.popular && \"border-primary shadow-lg ring-1 ring-primary lg:-mt-4 lg:pb-12\"\n                )}\n              >\n                {plan.popular && (\n                  <Badge color=\"primary\" className=\"absolute -top-3 left-1/2 -translate-x-1/2 rtl:translate-x-1/2\">\n                    Most popular\n                  </Badge>\n                )}\n                <div>\n                  <h3 className=\"text-lg font-semibold\">{plan.name}</h3>\n                  <p className=\"mt-1 text-sm text-muted-foreground\">{plan.blurb}</p>\n                </div>\n                <p className=\"flex items-baseline gap-1.5\">\n                  {/* A new price (monthly or yearly) counts to its amount. */}\n                  <span className=\"text-4xl font-semibold tracking-tight tabular-nums\">\n                    <Price value={price} money={money} />\n                  </span>\n                  <span className=\"text-sm text-muted-foreground\">{price ? (billing === \"yearly\" ? \"a month, billed yearly\" : \"a month\") : \"forever\"}</span>\n                </p>\n                {plan.href ? (\n                  <Button variant={plan.popular ? \"solid\" : \"outline\"} className=\"w-full\" asChild>\n                    <a href={plan.href}>{plan.cta}</a>\n                  </Button>\n                ) : (\n                  <Button variant={plan.popular ? \"solid\" : \"outline\"} className=\"w-full\" onClick={() => onSelect?.(plan, billing)}>\n                    {plan.cta}\n                  </Button>\n                )}\n                <ul className=\"grid gap-3 border-t pt-6 text-sm\">\n                  {plan.features.map((feature) => (\n                    <li key={feature} className=\"flex items-start gap-3\">\n                      <Check className=\"mt-0.5 size-4 shrink-0 text-primary-text\" aria-hidden />\n                      {feature}\n                    </li>\n                  ))}\n                </ul>\n              </div>\n            )\n          })}\n        </div>\n      </div>\n    </section>\n  )\n}\n"}],"cssVars":{"theme":{"color-primary-text":"var(--primary-text, var(--primary))"},"light":{},"dark":{}}}