BLK-02Blocks

Pricing Table UI | 3-Plan Comparison with a Recommended Plan, Responsive

A pricing table in React + Tailwind CSS with no dependencies. Copy the code, or pull it in with the npx shadcn command below as <PricingPlans data initialView showControls>. One dataset (a plans × features table) drives two views — Cards and a Feature comparison table — and switching keeps the recommended plan, prices and consult buttons aligned. A sample switch shows a Standard dataset and one with long plan names and uneven feature counts (2, 8 and 6 items). Under 640px the preview opens with a three-plan summary of names, tax-inclusive prices and the recommended badge; tapping one jumps to its card. Each plan carries a price-position scale where the most expensive plan fills the track. Prices lead with the tax-inclusive total and show the pre-tax price beside it, following the display examples in Japan's National Tax Agency Tax Answer No.6902. Pressing a consult button turns it into a Selected state and shows a consult message with the plan name plus copy success or failure right beside the button. prefers-reduced-motion stops the motion. Prices and features are sample data.

Preview

ライト

名刺代わりの小規模サイトに。

110,000円〜(税込)

税抜価格 100,000円〜

  • ページ数5ページまで
  • スマホ対応
  • お問い合わせフォーム

3項目 /

おすすめ

スタンダード

集客を意識した本格サイトに。

330,000円〜(税込)

税抜価格 300,000円〜

  • ページ数10ページまで
  • スマホ対応
  • お問い合わせフォーム
  • CMS導入(お知らせの更新)
  • 基本SEO設定
  • 公開後のサポート1か月

6項目 /

プレミアム

戦略から伴走する制作に。

550,000円〜(税込)

税抜価格 500,000円〜

  • ページ数無制限
  • スマホ対応
  • お問い合わせフォーム
  • CMS導入(お知らせの更新)
  • 基本SEO設定
  • LP・ブログ機能
  • アクセス解析の設定
  • 公開後のサポート月額保守

8項目 /

価格・機能は表示サンプル。価格は税込の総額を主に、税抜価格を添えています(消費税率10%で計算)。出典: 国税庁 タックスアンサー『No.6902 「総額表示」の義務付け』(令和8年4月1日現在法令等・2026-11-02 確認)。総額表示の義務は消費者に向けてあらかじめ表示する価格が対象です。

Share on X

Read the full description

A pricing table in React + Tailwind CSS with no dependencies. Copy the code, or pull it in with the npx shadcn command below as <PricingPlans data initialView showControls>. One dataset (a plans × features table) drives two views — Cards and a Feature comparison table — and switching keeps the recommended plan, prices and consult buttons aligned. A sample switch shows a Standard dataset and one with long plan names and uneven feature counts (2, 8 and 6 items). Under 640px the preview opens with a three-plan summary of names, tax-inclusive prices and the recommended badge; tapping one jumps to its card. Each plan carries a price-position scale where the most expensive plan fills the track. Prices lead with the tax-inclusive total and show the pre-tax price beside it, following the display examples in Japan's National Tax Agency Tax Answer No.6902. Pressing a consult button turns it into a Selected state and shows a consult message with the plan name plus copy success or failure right beside the button. prefers-reduced-motion stops the motion. Prices and features are sample data.

Added:
2026-07-23
Updated:
2026-11-02
Dependencies:
None
tags
#pricing #pricing-table #comparison #plan #responsive #section #react #tailwind #no-dependency
"use client";

import { useEffect, useRef, useState } from "react";

/**
 * 料金表UI(BLK-02)
 *
 * 1つのデータ(plans と features)から「カード」と「機能比較表」の2つの見せ方を作り、切り替えても
 * おすすめ・価格・相談ボタンの対応が崩れないようにした料金表。
 *
 * 技法メモ:
 * - features は「機能 × プラン」の表で持つ(true=対応 / false=なし / 文字=量や期間)。
 *   カードには false 以外を並べ、比較表には全行を並べる。プランごとに機能数が違っても同じデータで済む。
 * - 価格は税抜の数値だけを持ち、表示では税込の総額を主に、税抜を小さく添える
 *   (国税庁 タックスアンサー No.6902 の表示例「11,000円(税抜価格10,000円)」の形)。
 * - 各プランに「価格の位置」の細い目盛りを付け、いちばん高いプランを満幅として他のプランの位置に印を打つ。
 *   スマホでもカードを1枚読む前に、3プランの価格の開きが分かる。
 * - 640px 未満のカード表示では、冒頭に3プランの名前・価格・おすすめの一覧を置き、押すとそのカードへ移る。
 * - 相談ボタンを押すと、ボタン自体が「選択中」に変わり、カードの中に結果の一行、下に相談文とコピーが出る。
 *   コピーの成否はコピーボタンの隣に出す。状態の変化は 200ms 前後の opacity・transform だけで、
 *   prefers-reduced-motion: reduce では動かさずに切り替える。
 */

export type PlanFeatureValue = boolean | string;

export type Plan = {
  id: string;
  name: string;
  /** 税抜の価格(円)。表示は税込を主にする */
  priceExTax: number;
  desc: string;
  featured?: boolean;
};

export type PlanFeature = {
  id: string;
  label: string;
  values: Record<string, PlanFeatureValue>;
};

export type PricingData = { plans: Plan[]; features: PlanFeature[] };

const TAX_RATE_PERCENT = 10;

export const standardData: PricingData = {
  plans: [
    { id: "lite", name: "ライト", priceExTax: 100000, desc: "名刺代わりの小規模サイトに。" },
    { id: "standard", name: "スタンダード", priceExTax: 300000, desc: "集客を意識した本格サイトに。", featured: true },
    { id: "premium", name: "プレミアム", priceExTax: 500000, desc: "戦略から伴走する制作に。" },
  ],
  features: [
    { id: "pages", label: "ページ数", values: { lite: "5ページまで", standard: "10ページまで", premium: "無制限" } },
    { id: "responsive", label: "スマホ対応", values: { lite: true, standard: true, premium: true } },
    { id: "form", label: "お問い合わせフォーム", values: { lite: true, standard: true, premium: true } },
    { id: "cms", label: "CMS導入(お知らせの更新)", values: { lite: false, standard: true, premium: true } },
    { id: "seo", label: "基本SEO設定", values: { lite: false, standard: true, premium: true } },
    { id: "blog", label: "LP・ブログ機能", values: { lite: false, standard: false, premium: true } },
    { id: "analytics", label: "アクセス解析の設定", values: { lite: false, standard: false, premium: true } },
    { id: "support", label: "公開後のサポート", values: { lite: false, standard: "1か月", premium: "月額保守" } },
  ],
};

/** 長いプラン名と、プランごとに機能数が違う(2・8・6件)ときの表示例 */
export const unevenData: PricingData = {
  plans: [
    { id: "mini", name: "ミニマム(1ページLP)", priceExTax: 50000, desc: "告知用の1ページだけ。" },
    {
      id: "ops",
      name: "スタンダード+運用サポート(年間契約・月次レポート付き)",
      priceExTax: 480000,
      desc: "公開後の更新と改善まで任せたい方に。",
      featured: true,
    },
    { id: "ent", name: "エンタープライズ・多言語/複数拠点対応", priceExTax: 1200000, desc: "拠点や言語が多いサイトに。" },
  ],
  features: [
    { id: "pages", label: "ページ数", values: { mini: "1ページ", ops: "15ページまで", ent: "個別見積" } },
    { id: "responsive", label: "スマホ対応", values: { mini: true, ops: true, ent: true } },
    { id: "form", label: "お問い合わせフォーム", values: { mini: false, ops: true, ent: true } },
    { id: "cms", label: "CMS導入(お知らせの更新)", values: { mini: false, ops: true, ent: true } },
    { id: "seo", label: "基本SEO設定", values: { mini: false, ops: true, ent: false } },
    { id: "analytics", label: "アクセス解析の設定", values: { mini: false, ops: true, ent: false } },
    { id: "report", label: "改善レポート", values: { mini: false, ops: "毎月", ent: false } },
    { id: "support", label: "公開後のサポート", values: { mini: false, ops: "年間", ent: false } },
    { id: "lang", label: "多言語ページ", values: { mini: false, ops: false, ent: "3言語まで" } },
    { id: "branches", label: "拠点ページの一括管理", values: { mini: false, ops: false, ent: true } },
  ],
};

export function taxIncluded(priceExTax: number) {
  return Math.round((priceExTax * (100 + TAX_RATE_PERCENT)) / 100);
}

export function formatYen(n: number) {
  return n.toLocaleString("ja-JP");
}

/** 一覧用の短い書き方(330000 → "33万円") */
export function formatManYen(n: number) {
  return `${Math.round(n / 1000) / 10}万円`;
}

/** カードに並べる機能(false を除く) */
export function planFeatures(plan: Plan, features: PlanFeature[]) {
  return features
    .filter((f) => f.values[plan.id] !== undefined && f.values[plan.id] !== false)
    .map((f) => ({ id: f.id, label: f.label, value: f.values[plan.id] }));
}

export function buildConsultText(plan: Plan, features: PlanFeature[]) {
  const items = planFeatures(plan, features).map((f) =>
    typeof f.value === "string" ? `${f.label}(${f.value})` : f.label,
  );
  return [
    `【相談したいプラン】${plan.name}`,
    `【目安の価格】${formatYen(taxIncluded(plan.priceExTax))}円〜(税込・税抜価格${formatYen(plan.priceExTax)}円〜)`,
    `【含まれる内容】${items.join("、")}`,
    "【相談したいこと】",
  ].join("\n");
}

function useReducedMotion() {
  const [reduced, setReduced] = useState(false);
  useEffect(() => {
    const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
    const update = () => setReduced(mq.matches);
    update();
    mq.addEventListener("change", update);
    return () => mq.removeEventListener("change", update);
  }, []);
  return reduced;
}

type View = "cards" | "table";
type DataKey = "standard" | "uneven";
type CopyState = "idle" | "ok" | "error";

const datasets: Record<DataKey, PricingData> = { standard: standardData, uneven: unevenData };

const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600";
const fade = "transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none";

function Check({ className = "" }: { className?: string }) {
  return (
    <svg className={`size-3.5 shrink-0 ${className}`} viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
      <path fillRule="evenodd" d="M16.7 5.3a1 1 0 0 1 0 1.4l-8 8a1 1 0 0 1-1.4 0l-4-4a1 1 0 1 1 1.4-1.4L8 12.6l7.3-7.3a1 1 0 0 1 1.4 0Z" clipRule="evenodd" />
    </svg>
  );
}

function Segmented<T extends string>({
  label,
  value,
  options,
  onChange,
}: {
  label: string;
  value: T;
  options: { key: T; label: string }[];
  onChange: (v: T) => void;
}) {
  return (
    <div role="group" aria-label={label} className="inline-flex rounded-full border border-gray-200 bg-white p-1">
      {options.map((opt) => (
        <button
          key={opt.key}
          type="button"
          aria-pressed={value === opt.key}
          onClick={() => onChange(opt.key)}
          className={`min-h-9 rounded-full px-3 text-xs font-semibold transition-[background-color,color,transform] duration-150 active:scale-[0.96] motion-reduce:transition-none motion-reduce:active:scale-100 ${focusRing} ${
            value === opt.key ? "bg-gray-900 text-white" : "text-gray-600 hover:text-gray-900"
          }`}
        >
          {opt.label}
        </button>
      ))}
    </div>
  );
}

/** 価格の位置: いちばん高いプランを満幅にし、他のプランの位置に印を打つ */
function PriceScale({ plan, plans, dark = false }: { plan: Plan; plans: Plan[]; dark?: boolean }) {
  const max = Math.max(...plans.map((p) => p.priceExTax));
  return (
    <div className={`relative h-1 rounded-full ${dark ? "bg-white/15" : "bg-gray-100"}`} aria-hidden="true">
      <div
        className={`absolute inset-y-0 left-0 rounded-full ${plan.featured ? "bg-amber-500" : dark ? "bg-white/70" : "bg-gray-400"}`}
        style={{ width: `${(plan.priceExTax / max) * 100}%` }}
      />
      {plans
        .filter((p) => p.id !== plan.id)
        .map((p) => (
          <span
            key={p.id}
            className={`absolute top-1/2 h-2.5 w-px -translate-y-1/2 ${dark ? "bg-white/40" : "bg-gray-300"}`}
            style={{ left: `${(p.priceExTax / max) * 100}%` }}
          />
        ))}
    </div>
  );
}

function Price({ plan, dark = false, size = "card" }: { plan: Plan; dark?: boolean; size?: "card" | "table" }) {
  const muted = dark ? "text-gray-300" : "text-gray-500";
  return (
    <div>
      <p className="flex flex-wrap items-baseline gap-x-1">
        <span className={`${size === "card" ? "text-[28px]" : "text-xl"} font-bold tracking-tight tabular-nums ${dark ? "text-white" : "text-gray-900"}`}>
          {formatYen(taxIncluded(plan.priceExTax))}
        </span>
        <span className={`text-xs font-medium ${muted}`}>円〜(税込)</span>
      </p>
      <p className={`mt-0.5 text-[11px] tabular-nums ${muted}`}>税抜価格 {formatYen(plan.priceExTax)}円〜</p>
    </div>
  );
}

function ConsultButton({
  plan,
  selected,
  onSelect,
  compact = false,
}: {
  plan: Plan;
  selected: boolean;
  onSelect: (plan: Plan) => void;
  compact?: boolean;
}) {
  return (
    <button
      type="button"
      aria-pressed={selected}
      aria-label={`${plan.name}で相談する`}
      onClick={() => onSelect(plan)}
      className={`inline-flex w-full min-h-11 items-center justify-center gap-1.5 rounded-lg px-3 text-center font-semibold transition-[background-color,color,box-shadow,transform] duration-150 active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100 ${focusRing} ${
        compact ? "text-xs" : "text-sm"
      } ${
        selected
          ? "bg-amber-50 text-amber-800 ring-2 ring-amber-500"
          : plan.featured
            ? "bg-amber-600 text-white hover:bg-amber-700"
            : "border border-gray-300 bg-white text-gray-800 hover:bg-gray-50"
      }`}
    >
      {selected && <Check className="text-amber-600" />}
      {selected ? "選択中" : compact ? "相談する" : "このプランで相談"}
    </button>
  );
}

export default function PricingPlans({
  data,
  initialView = "cards",
  showControls = true,
}: {
  /** 渡すと見本のデータ切り替えを出さず、このデータだけで描く */
  data?: PricingData;
  initialView?: View;
  showControls?: boolean;
  /** ギャラリーの表示枠が渡す見出しの指定。この部品はプラン名を h3 で固定するため使わない */
  headingTag?: "h1" | "p";
}) {
  const [view, setView] = useState<View>(initialView);
  const [dataKey, setDataKey] = useState<DataKey>("standard");
  const [selectedId, setSelectedId] = useState<string | null>(null);
  const [shown, setShown] = useState(false);
  const [copy, setCopy] = useState<CopyState>("idle");
  const [flashId, setFlashId] = useState<string | null>(null);
  const reduced = useReducedMotion();
  const cardRefs = useRef<Record<string, HTMLElement | null>>({});
  const timers = useRef<number[]>([]);

  const { plans, features } = data ?? datasets[dataKey];
  const selected = plans.find((p) => p.id === selectedId) ?? null;
  const consultText = selected ? buildConsultText(selected, features) : "";

  useEffect(() => () => timers.current.forEach((t) => window.clearTimeout(t)), []);

  const later = (fn: () => void, ms: number) => {
    timers.current.push(window.setTimeout(fn, ms));
  };

  const choose = (plan: Plan) => {
    setSelectedId(plan.id);
    setCopy("idle");
    if (reduced) {
      setShown(true);
      return;
    }
    // 選び直したときも結果欄を一度消してから出し、押した結果が変わったことを見せる
    setShown(false);
    requestAnimationFrame(() => requestAnimationFrame(() => setShown(true)));
  };

  const switchData = (key: DataKey) => {
    setDataKey(key);
    setSelectedId(null);
    setShown(false);
    setCopy("idle");
  };

  const jumpTo = (plan: Plan) => {
    const el = cardRefs.current[plan.id];
    if (!el) return;
    el.scrollIntoView({ behavior: reduced ? "auto" : "smooth", block: "center" });
    setFlashId(plan.id);
    later(() => setFlashId((id) => (id === plan.id ? null : id)), 900);
  };

  const copyText = async () => {
    try {
      await navigator.clipboard.writeText(consultText);
      setCopy("ok");
    } catch {
      setCopy("error");
    }
    later(() => setCopy((s) => (s === "ok" ? "idle" : s)), 2400);
  };

  return (
    <div className="w-full min-w-0 max-w-3xl text-gray-900">
      {showControls && (
        <div className="mb-4 flex flex-wrap items-center gap-1.5 sm:mb-8 sm:gap-2">
          <Segmented
            label="表示の切り替え"
            value={view}
            onChange={setView}
            options={[
              { key: "cards", label: "カード" },
              { key: "table", label: "機能比較表" },
            ]}
          />
          {!data && (
            <Segmented
              label="表示例のデータ"
              value={dataKey}
              onChange={switchData}
              options={[
                { key: "standard", label: "標準" },
                { key: "uneven", label: "長い名前・項目数差" },
              ]}
            />
          )}
        </div>
      )}

      {view === "cards" ? (
        <>
          {/* 640px 未満: 3プランの名前・価格・おすすめを先に一覧で見せる */}
          <ul className="mb-4 grid grid-cols-3 gap-1.5 sm:hidden" aria-label="プランの一覧">
            {plans.map((plan) => (
              <li key={plan.id}>
                <button
                  type="button"
                  onClick={() => jumpTo(plan)}
                  className={`flex h-full w-full flex-col gap-1.5 rounded-xl border p-2.5 text-left transition-transform duration-150 active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100 ${focusRing} ${
                    plan.featured ? "border-gray-900 bg-gray-900 text-white" : "border-gray-200 bg-white"
                  }`}
                >
                  <span className={`text-[10px] font-bold ${plan.featured ? "text-amber-400" : "text-transparent"}`} aria-hidden={!plan.featured}>
                    {plan.featured ? "おすすめ" : "-"}
                  </span>
                  {plan.featured && <span className="sr-only">おすすめ</span>}
                  <span className="line-clamp-2 text-xs font-bold leading-snug break-words">{plan.name}</span>
                  <span className="mt-auto text-sm font-bold tabular-nums">
                    {formatManYen(taxIncluded(plan.priceExTax))}
                    <span className={`text-[10px] font-medium ${plan.featured ? "text-gray-300" : "text-gray-500"}`}>〜</span>
                  </span>
                  <PriceScale plan={plan} plans={plans} dark={plan.featured} />
                </button>
              </li>
            ))}
          </ul>

          <div className="grid gap-4 sm:grid-cols-3 sm:items-stretch sm:gap-4">
            {plans.map((plan) => {
              const dark = !!plan.featured;
              const items = planFeatures(plan, features);
              const isSelected = selectedId === plan.id;
              return (
                <article
                  key={plan.id}
                  ref={(el) => {
                    cardRefs.current[plan.id] = el;
                  }}
                  className={`relative flex min-w-0 scroll-m-4 flex-col rounded-2xl p-5 transition-shadow duration-300 motion-reduce:transition-none sm:p-6 ${
                    dark ? "bg-gray-900 text-white shadow-lg sm:-my-3 sm:py-9" : "border border-gray-200 bg-white shadow-sm"
                  } ${flashId === plan.id ? "ring-4 ring-amber-300" : ""}`}
                >
                  {plan.featured && (
                    <span className="absolute -top-3 left-5 rounded-full bg-amber-500 px-3 py-1 text-xs font-bold text-gray-900 sm:left-1/2 sm:-translate-x-1/2">
                      おすすめ
                    </span>
                  )}
                  <h3 className={`text-sm font-bold leading-snug break-words ${dark ? "text-white" : "text-gray-900"}`}>{plan.name}</h3>
                  <p className={`mt-1 text-xs leading-relaxed ${dark ? "text-gray-300" : "text-gray-500"}`}>{plan.desc}</p>
                  <div className="mt-4">
                    <Price plan={plan} dark={dark} />
                  </div>
                  <div className="mt-3">
                    <PriceScale plan={plan} plans={plans} dark={dark} />
                  </div>
                  <ul className="mt-5 flex-1 space-y-2.5" aria-label={`${plan.name}に含まれる内容`}>
                    {items.map((f) => (
                      <li key={f.id} className={`flex items-start gap-2 text-xs leading-relaxed ${dark ? "text-gray-200" : "text-gray-600"}`}>
                        <Check className={`mt-0.5 ${dark ? "text-amber-400" : "text-amber-600"}`} />
                        <span className="min-w-0">
                          {f.label}
                          {typeof f.value === "string" && (
                            <span className={`ml-1 font-semibold ${dark ? "text-white" : "text-gray-900"}`}>{f.value}</span>
                          )}
                        </span>
                      </li>
                    ))}
                  </ul>
                  <p className={`mt-4 text-[11px] ${dark ? "text-gray-400" : "text-gray-400"}`}>
                    {items.length}項目 /{" "}
                    <button
                      type="button"
                      onClick={() => setView("table")}
                      className={`underline underline-offset-2 ${dark ? "hover:text-white" : "hover:text-gray-700"} ${focusRing}`}
                    >
                      他のプランと比べる
                    </button>
                  </p>
                  <div className="mt-4">
                    <ConsultButton plan={plan} selected={isSelected} onSelect={choose} />
                  </div>
                  <p
                    aria-hidden="true"
                    className={`text-center text-[11px] ${fade} ${dark ? "text-amber-300" : "text-amber-700"} ${
                      isSelected && shown ? "mt-2 h-auto translate-y-0 opacity-100" : "h-0 -translate-y-1 overflow-hidden opacity-0"
                    }`}
                  >
                    相談文に「{plan.name}」を入れました
                  </p>
                </article>
              );
            })}
          </div>
        </>
      ) : (
        <div>
          <div
            role="region"
            aria-label="プランの機能比較表(横にスクロールできます)"
            tabIndex={0}
            className={`relative overflow-x-auto rounded-xl border border-gray-200 bg-white ${focusRing}`}
          >
            <table className="w-full min-w-[520px] table-fixed border-collapse text-left">
              <caption className="sr-only">プランごとの価格と含まれる内容</caption>
              <colgroup>
                <col className="w-[28%]" />
                {plans.map((p) => (
                  <col key={p.id} />
                ))}
              </colgroup>
              <thead>
                <tr>
                  <th scope="col" className="sticky left-0 z-10 bg-white p-3 align-bottom text-[11px] font-semibold text-gray-400">
                    プラン
                  </th>
                  {plans.map((plan) => (
                    <th
                      key={plan.id}
                      scope="col"
                      className={`p-3 align-top font-normal ${plan.featured ? "bg-gray-900 text-white" : ""}`}
                    >
                      <span className={`block h-5 text-[10px] font-bold ${plan.featured ? "text-amber-400" : ""}`}>
                        {plan.featured ? "おすすめ" : ""}
                      </span>
                      <span className="block text-xs font-bold leading-snug break-words">{plan.name}</span>
                      <span className="mt-2 block">
                        <Price plan={plan} dark={plan.featured} size="table" />
                      </span>
                    </th>
                  ))}
                </tr>
              </thead>
              <tbody>
                {features.map((f) => (
                  <tr key={f.id}>
                    <th scope="row" className="sticky left-0 z-10 border-t border-gray-100 bg-white p-3 text-xs font-medium text-gray-700">
                      {f.label}
                    </th>
                    {plans.map((plan) => {
                      const v = f.values[plan.id];
                      return (
                        <td
                          key={plan.id}
                          className={`border-t p-3 text-center text-xs ${plan.featured ? "border-amber-100 bg-amber-50" : "border-gray-100"}`}
                        >
                          {typeof v === "string" ? (
                            <span className="font-semibold text-gray-900">{v}</span>
                          ) : v ? (
                            <>
                              <Check className="mx-auto text-amber-600" />
                              <span className="sr-only">対応</span>
                            </>
                          ) : (
                            <>
                              <span className="mx-auto block h-px w-3 bg-gray-300" aria-hidden="true" />
                              <span className="sr-only">なし</span>
                            </>
                          )}
                        </td>
                      );
                    })}
                  </tr>
                ))}
              </tbody>
              <tfoot>
                <tr>
                  <td className="sticky left-0 z-10 border-t border-gray-200 bg-white p-3" />
                  {plans.map((plan) => (
                    <td
                      key={plan.id}
                      className={`border-t p-3 ${plan.featured ? "border-amber-100 bg-amber-50" : "border-gray-200"}`}
                    >
                      <ConsultButton plan={plan} selected={selectedId === plan.id} onSelect={choose} compact />
                    </td>
                  ))}
                </tr>
              </tfoot>
            </table>
          </div>
          <p className="mt-2 text-[11px] text-gray-400 sm:hidden">← 横にスワイプして全プランを比較</p>
        </div>
      )}

      {/* 相談ボタンの結果: 選んだプラン名入りの相談文と、コピーの成否 */}
      <div aria-live="polite">
        {selected && (
          <div
            className={`mt-6 rounded-xl border border-amber-200 bg-amber-50/60 p-4 ${fade} ${
              shown ? "translate-y-0 opacity-100" : "translate-y-1 opacity-0"
            }`}
          >
            <p className="text-sm font-bold text-gray-900">
              「{selected.name}」で相談する内容を用意しました
            </p>
            <pre className="mt-2 whitespace-pre-wrap break-words rounded-lg border border-amber-100 bg-white p-3 font-sans text-xs leading-relaxed text-gray-700">
              {consultText}
            </pre>
            <div className="mt-3 flex flex-wrap items-center gap-x-3 gap-y-1">
              <button
                type="button"
                onClick={copyText}
                className={`inline-flex min-h-11 items-center rounded-lg border border-gray-300 bg-white px-4 text-sm font-semibold text-gray-800 transition-transform duration-150 hover:bg-gray-50 active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100 ${focusRing}`}
              >
                相談文をコピー
              </button>
              <span
                role="status"
                className={`text-xs font-semibold ${fade} ${copy === "idle" ? "opacity-0" : "opacity-100"} ${
                  copy === "error" ? "text-red-700" : "text-emerald-700"
                }`}
              >
                {copy === "ok" && "コピーしました"}
                {copy === "error" && "コピーできませんでした。上の文面を選んでコピーしてください"}
              </span>
            </div>
          </div>
        )}
      </div>

      <p className="mt-6 text-[11px] leading-relaxed text-gray-400">
        価格・機能は表示サンプル。価格は税込の総額を主に、税抜価格を添えています(消費税率{TAX_RATE_PERCENT}%で計算)。出典:{" "}
        <a
          href="https://www.nta.go.jp/taxes/shiraberu/taxanswer/shohi/6902.htm"
          className={`underline underline-offset-2 hover:text-gray-600 ${focusRing}`}
          target="_blank"
          rel="noreferrer"
        >
          国税庁 タックスアンサー『No.6902 「総額表示」の義務付け』
        </a>
        (令和8年4月1日現在法令等・2026-11-02 確認)。総額表示の義務は消費者に向けてあらかじめ表示する価格が対象です。
      </p>
    </div>
  );
}

Add to your project via shadcn CLI

npx shadcn@latest add https://designs.first-ch.com/r/pricing-plans.json