{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"plan-comparison","type":"registry:block","title":"Plan comparison","description":"Compare meaningful differences between plans and billing periods.","categories":["blocks"],"dependencies":["lucide-react","motion"],"registryDependencies":["https://uiarc.dev/r/arc-motion-tokens.json","https://uiarc.dev/r/button.json","https://uiarc.dev/r/segmented-control.json","https://uiarc.dev/r/switch.json"],"files":[{"path":"registry/blocks/plan-comparison/plan-comparison.tsx","type":"registry:component","target":"@components/arc/blocks/plan-comparison/plan-comparison.tsx","content":"\"use client\";\n\nimport { useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { animate, AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Check } from \"lucide-react\";\nimport { Button } from \"../../button/button\";\nimport SegmentedControl from \"../../segmented-control/segmented-control\";\nimport { Switch } from \"../../switch/switch\";\nimport { motionTokens } from \"../../lib/motion-tokens\";\nimport styles from \"./plan-comparison.module.css\";\n\ntype Plan = \"team\" | \"studio\";\ntype Billing = \"monthly\" | \"yearly\";\ntype Feature = { label: string; team: string; studio: string; shared?: boolean };\n\nconst features: Feature[] = [\n  { label: \"Active projects\", team: \"Unlimited\", studio: \"Unlimited\", shared: true },\n  { label: \"Shared workspaces\", team: \"1 workspace\", studio: \"Unlimited\" },\n  { label: \"Guest reviewers\", team: \"5 per project\", studio: \"Unlimited\" },\n  { label: \"Version history\", team: \"30 days\", studio: \"Unlimited\" },\n  { label: \"Approval flows\", team: \"Not included\", studio: \"Included\" },\n  { label: \"Custom roles\", team: \"Not included\", studio: \"Included\" },\n  { label: \"Source exports\", team: \"Included\", studio: \"Included\", shared: true },\n  { label: \"Support\", team: \"Email\", studio: \"Priority email\" },\n];\n\nconst pricing: Record<Plan, Record<Billing, number>> = {\n  team: { monthly: 13, yearly: 10 },\n  studio: { monthly: 27, yearly: 22 },\n};\n\nfunction Value({ text }: { text: string }) {\n  if (text === \"Included\") return <span className={styles.included}><Check size={16} strokeWidth={1.75} aria-hidden=\"true\" />Included</span>;\n  return <span className={text === \"Not included\" ? styles.unavailable : undefined}>{text}</span>;\n}\n\nfunction AnimatedNumber({ value }: { value: number }) {\n  const reduce = useReducedMotion();\n  const [displayValue, setDisplayValue] = useState(value);\n  const previousValue = useRef(value);\n\n  useEffect(() => {\n    if (reduce) {\n      previousValue.current = value;\n      return;\n    }\n\n    const controls = animate(previousValue.current, value, {\n      duration: motionTokens.duration.standard,\n      ease: [...motionTokens.ease.enter],\n      onUpdate: (latest) => setDisplayValue(Math.round(latest)),\n    });\n\n    previousValue.current = value;\n    return () => controls.stop();\n  }, [reduce, value]);\n\n  return <>{reduce ? value : displayValue}</>;\n}\n\nexport function PlanComparison() {\n  const id = useId();\n  const reduce = useReducedMotion();\n  const [billing, setBilling] = useState<Billing>(\"monthly\");\n  const [differencesOnly, setDifferencesOnly] = useState(false);\n  const [selected, setSelected] = useState<Plan | null>(null);\n  const rootRef = useRef<HTMLElement>(null);\n  const [size, setSize] = useState<\"lg\" | \"md\" | \"sm\" | \"xs\">(\"lg\");\n  useLayoutEffect(() => {\n    const node = rootRef.current;\n    if (!node) return;\n    const measure = (width: number) => setSize(width <= 340 ? \"xs\" : width <= 540 ? \"sm\" : width <= 720 ? \"md\" : \"lg\");\n    measure(node.getBoundingClientRect().width);\n    const observer = new ResizeObserver(([entry]) => { if (entry) measure(entry.contentRect.width); });\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, []);\n  const visibleFeatures = differencesOnly ? features.filter((feature) => !feature.shared) : features;\n\n  return (\n    <section ref={rootRef} className={styles.comparison} data-size={size} aria-labelledby={`${id}-title`}>\n      <div className={styles.intro}>\n        <div><h2 id={`${id}-title`}>Room for the way you work</h2><p>Only the details that change between plans. Switch billing to see what you would pay.</p></div>\n        <div className={styles.billing}><SegmentedControl label=\"Billing period\" value={billing} onValueChange={(value) => setBilling(value as Billing)} options={[{ value: \"monthly\", label: \"Monthly\" }, { value: \"yearly\", label: \"Yearly\" }]} /><small>{billing === \"yearly\" ? \"Billed yearly, save up to 23%\" : \"Billed month to month\"}</small></div>\n      </div>\n\n      <div className={styles.filter}><div><h3>Compare plans</h3><span className={styles.featureCount}><AnimatedNumber value={visibleFeatures.length} /> of {features.length} features</span></div><Switch checked={differencesOnly} onCheckedChange={setDifferencesOnly} label=\"Show differences only\" /></div>\n\n      <div className={styles.matrix} role=\"table\" aria-label=\"Team and Studio plan comparison\">\n        <div className={styles.planHeader} role=\"row\">\n          <div className={styles.featureHeader} role=\"columnheader\">What changes</div>\n          {([\"team\", \"studio\"] as const).map((plan) => (\n            <div key={plan} className={`${styles.planCell} ${selected === plan ? styles.planSelected : \"\"}`} role=\"columnheader\" aria-label={`${plan === \"team\" ? \"Team\" : \"Studio\"} plan`}>\n              <div className={styles.planTop}><h3>{plan === \"team\" ? \"Team\" : \"Studio\"}</h3><span>{plan === \"team\" ? \"For smaller teams\" : \"For work across teams\"}</span></div>\n              <div className={styles.price}><span className={styles.priceValue} aria-live=\"polite\" aria-atomic=\"true\">$<AnimatedNumber value={pricing[plan][billing]} /></span><span className={styles.pricePeriod}>per seat / month</span></div>\n              <Button type=\"button\" variant={selected === plan ? \"primary\" : \"secondary\"} className={styles.selectButton} aria-pressed={selected === plan} onClick={() => setSelected(current => current === plan ? null : plan)}>{selected === plan ? \"Selected\" : `Select ${plan === \"team\" ? \"Team\" : \"Studio\"}`}</Button>\n              {selected === plan && <motion.span className={styles.selectedRail} layoutId={`${id}-selected-rail`} transition={reduce ? { duration: 0 } : motionTokens.spring.responsive} aria-hidden=\"true\" />}\n            </div>\n          ))}\n        </div>\n\n        <div className={styles.rows} role=\"rowgroup\">\n          <AnimatePresence initial={false}>\n            {visibleFeatures.map((feature) => (\n              <motion.div key={feature.label} className={styles.featureRow} role=\"row\" initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0, transition: { height: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.fast } } }} transition={reduce ? { duration: 0 } : { height: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.standard, ease: [...motionTokens.ease.enter], delay: .04 } }}>\n                <div className={styles.featureName} role=\"rowheader\">{feature.label}</div>\n                <div className={`${styles.featureValue} ${selected === \"team\" ? styles.valueSelected : \"\"}`} role=\"cell\"><span className={styles.mobilePlan}>Team</span><Value text={feature.team} /></div>\n                <div className={`${styles.featureValue} ${selected === \"studio\" ? styles.valueSelected : \"\"}`} role=\"cell\"><span className={styles.mobilePlan}>Studio</span><Value text={feature.studio} /></div>\n              </motion.div>\n            ))}\n          </AnimatePresence>\n        </div>\n      </div>\n\n      <div className={styles.footer}><span>Prices in USD per seat. Yearly plans are billed annually.</span><p className={styles.srOnly} role=\"status\" aria-live=\"polite\">{selected ? `${selected === \"team\" ? \"Team\" : \"Studio\"} selected` : \"\"}</p></div>\n    </section>\n  );\n}\n\nexport default PlanComparison;\n"},{"path":"registry/blocks/plan-comparison/plan-comparison.module.css","type":"registry:component","target":"@components/arc/blocks/plan-comparison/plan-comparison.module.css","content":".comparison { box-sizing: border-box; width: min(100%, 1060px); min-width: 0; margin-inline: auto; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--surface); color: var(--foreground); font-family: var(--font-body); font-size: var(--text-sm); letter-spacing: var(--tracking-body); line-height: var(--leading-body); }\n.comparison *, .comparison *::before, .comparison *::after { box-sizing: border-box; }\n\n/* Intro */\n.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 32px; padding: 32px 32px 24px; }\n.intro > div:first-child { min-width: 0; max-width: 560px; }\n.intro h2 { margin: 0; font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 400; letter-spacing: var(--tracking-display); line-height: var(--leading-display); text-wrap: balance; }\n.intro p { max-width: 46ch; margin: 8px 0 0; color: var(--text-secondary); text-wrap: pretty; }\n.billing { display: grid; flex: none; justify-items: end; gap: 6px; }\n.billing small { min-height: 16px; color: var(--text-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }\n\n/* Filter bar */\n.filter { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 8px 16px; border-top: 1px solid var(--border); padding: 8px 32px; }\n.filter > div:first-child { display: flex; align-items: baseline; gap: 10px; }\n.filter h3 { margin: 0; font-size: var(--text-sm); font-weight: 500; }\n.featureCount { min-width: 11ch; color: var(--text-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }\n.filter > button { flex: none; }\n\n/* Matrix */\n.matrix { border-top: 1px solid var(--border); }\n.planHeader, .featureRow { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); }\n/* Plan cells share three row tracks (name, price, button), so a description that wraps in one column keeps prices and buttons level. */\n.planHeader { grid-template-rows: auto auto auto; }\n.featureHeader { grid-row: 1 / span 3; display: flex; align-items: end; padding: 0 16px 20px 32px; color: var(--text-muted); font-size: var(--text-xs); }\n.planCell { position: relative; display: grid; grid-row: span 3; grid-template-rows: subgrid; min-width: 0; align-content: start; border-left: 1px solid var(--border); padding: 20px; transition: background-color var(--duration-standard) var(--ease-standard); }\n.planCell.planSelected, .featureValue.valueSelected { background: var(--surface-muted); }\n.planTop h3 { margin: 0; font-size: var(--text-base); font-weight: 500; letter-spacing: -.01em; }\n.planTop > span { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--text-xs); }\n.price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin: 16px 0 14px; }\n.priceValue { display: inline-flex; min-width: 3ch; font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 400; letter-spacing: var(--tracking-display); line-height: 1; font-variant-numeric: tabular-nums; }\n.pricePeriod { color: var(--text-muted); font-size: var(--text-xs); white-space: nowrap; }\n.selectButton { width: 100%; }\n.selectedRail { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); }\n.rows { border-top: 1px solid var(--border); }\n.featureRow { overflow: hidden; border-bottom: 1px solid var(--border-subtle); }\n.featureRow:last-child { border-bottom: 0; }\n.featureName, .featureValue { display: flex; min-width: 0; min-height: 44px; align-items: center; padding: 10px 20px; }\n.featureName { padding-left: 32px; color: var(--foreground); }\n.featureValue { border-left: 1px solid var(--border); color: var(--text-secondary); transition: background-color var(--duration-standard) var(--ease-standard), color var(--duration-standard) var(--ease-standard); }\n.featureValue.valueSelected { color: var(--foreground); }\n.included { display: inline-flex; align-items: center; gap: 6px; color: var(--foreground); }\n.included svg { color: var(--success); }\n.unavailable { color: var(--text-muted); }\n.mobilePlan { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n\n.footer { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 8px 24px; border-top: 1px solid var(--border); padding: 12px 32px; color: var(--text-muted); font-size: var(--text-xs); }\n.footer p { min-height: 1.4em; margin: 0; color: var(--text-secondary); text-align: right; }\n\n@media (hover: hover) and (pointer: fine) {\n  .featureRow:hover .featureName { color: var(--foreground); }\n}\n\n/* Layout follows the block width (data-size, measured in the component), not the viewport. */\n/* Medium: keep three columns, tighten the gutters. */\n.comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .intro { flex-direction: column; align-items: flex-start; padding: 24px 20px 20px; }\n.comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .billing { justify-items: start; }\n.comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .filter { padding-inline: 20px; }\n.comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .featureHeader, .comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .featureName { padding-left: 20px; }\n.comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .planCell { padding: 16px 14px; }\n.comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .featureValue { padding-inline: 14px; }\n.comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .footer { flex-direction: column; align-items: flex-start; padding-inline: 20px; }\n.comparison:is([data-size=\"md\"], [data-size=\"sm\"], [data-size=\"xs\"]) .footer p { text-align: left; }\n\n/* Narrow: the feature name sits above its two values, which stay aligned under the plan columns. */\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .intro h2 { font-size: var(--text-2xl); }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .filter { flex-wrap: wrap; }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .planHeader, .comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .featureRow { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .featureHeader { display: none; }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .planCell { border-left: 0; }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .planCell + .planCell { border-left: 1px solid var(--border); }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .priceValue { font-size: var(--text-2xl); }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .featureName { grid-column: 1 / -1; min-height: 0; padding: 10px 20px 0; color: var(--text-secondary); font-size: var(--text-xs); }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .featureValue { min-height: 0; border-left: 0; padding: 4px 14px 10px; }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .featureValue:nth-child(2) { padding-left: 20px; }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .featureValue + .featureValue { border-left: 1px solid var(--border-subtle); }\n.comparison:is([data-size=\"sm\"], [data-size=\"xs\"]) .planCell:nth-child(2) { padding-left: 20px; }\n.comparison[data-size=\"xs\"] .planCell { padding-inline: 12px; }\n.comparison[data-size=\"xs\"] .planCell:nth-child(2) { padding-left: 16px; }\n.comparison[data-size=\"xs\"] .featureValue { padding-inline: 12px; }\n.comparison[data-size=\"xs\"] .featureValue:nth-child(2) { padding-left: 16px; }\n.comparison[data-size=\"xs\"] .featureName { padding-inline: 16px; }\n.comparison[data-size=\"xs\"] .intro, .comparison[data-size=\"xs\"] .filter, .comparison[data-size=\"xs\"] .footer { padding-inline: 16px; }\n@media (prefers-reduced-motion: reduce) {\n  .planCell, .featureValue { transition: none; }\n}\n\n.srOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n"}],"docs":"Use this when people need to weigh plans side by side. Replace the sample features and prices with your current offering.","meta":{"tier":"free","kind":"block","builtFrom":["Segmented control","Button","Motion"],"docs":"https://uiarc.dev/components/blocks/plan-comparison"}}