shadcn.io is not affiliated with official shadcn/ui
Compare Tray Pricing Block for React
A comparison tray for four plans: tick any two or more and the tray opens as a side-by-side table of just those plans, with their prices and calls to action at its head.
Installation
Overview
Let buyers build their own comparison with this compare tray pricing section. The tray is the hero: under a compact header with a live count and a Clear all button, a row of four plan chips, each a Toggle with a tick box, and under them the tray itself, open from the start on a Table of the two plans ticked by default. Its head carries each plan's price at display size and a call to action, so the buyer can act without scrolling, then the limits run row by row: events, overage rate, retention, projects, session replay, SQL access, single sign-on, support and uptime, with checks, dashes and text. Tick another chip and its column joins the table; untick one and it leaves; with fewer than two the tray closes. Growth, the popular plan, is tinted in the table and holds the one primary Shine Button. On a phone the table scrolls sideways under a pinned feature column and an edge fade. The section sits on the page's drafting lines, drawn by Guides: rails at the edges of the page column, a rule along its top with a plus on each crossing, and a ruled band around the chips with a plus at each corner. Built with Toggle, Table, Badge, Button, Guides, Shine Button and Lucide icons, with CSS transitions only. For analytics, infrastructure and developer tools with four or more plans, where most buyers weigh two or three of them.
FAQ
How do I change the plans and the comparison rows?
Edit PLANS for the chips and the table's head (each plan has its name, amount, the chip's chip line, the price's note, the call to action's cta and href, and popular) and ROWS for the limits. A row has a label and a values record keyed by plan id: true shows a check, false a dash, and text shows as written. MIN_COMPARED is how many plans open the tray, and the starting list in useState (Growth and Business) is what's ticked on load: change it to open on others, or on none.
How does the tray open and close?
It's a CSS grid whose single row grows from 0fr to 1fr, with a fade, once enough plans are ticked, so it opens to its content's height without measuring it. Closed, the panel is inert: its table and links can't be tabbed into or read until it opens. The columns follow the plans' order, whatever order they were ticked in. Under reduced motion it opens at once.
Is the compare tray accessible?
Each chip is a toggle button named for its plan, such as "Growth, $0.00025 an event", and announces whether it's pressed; the tick box is decorative. The status line in the header is a polite live region, so ticking a plan announces "Comparing 3 of 4 plans" or how many more are needed, without reading the table. The table has column and row headers, so a screen reader names the plan and the feature for each cell; checks and dashes read as Included and Not included. The scrolling table is a labelled region you can reach with Tab and scroll with the arrow keys.
How does the tray work on a phone?
The chips become a two-by-two grid and the table keeps its columns at a readable width, so it scrolls sideways. The feature column is pinned with a rule on its edge, and a fade on the table's end edge shows there is more to scroll. Each plan's price and call to action sit at the head of its column, so the first screen already holds the chips and the first button.
How do I connect the buttons to checkout, and keep the comparison?
Each call to action is a real link to its plan's href. It's a ShineButton with render set to an a element and nativeButton={false}. The ticked plans are a plain array of ids, so you can add them to the link (/signup?plan=growth&compared=growth,business) to learn which plans buyers weigh against each other, or keep them in the URL so a shared link reopens the same comparison.
When should I use a compare tray instead of a full comparison table?
Use a tray when you sell four or more plans but most buyers decide between two or three: the chips stay small and the detail appears only for the plans they care about. Show the full comparison table when buyers, such as procurement teams, need to see every plan against every other at once.
Related
- Pro
Comparison Table Pricing
Comparison tablesFour plans compared feature by feature in one table whose hairlines meet the page rails, with a billing switch, a tinted popular column and, on a phone, a plan switch that keeps the feature column beside one plan.
- Pro
Feature Matrix Pricing
Comparison tablesA feature matrix you can interrogate: search the features, hide the rows every plan shares with a switch, and watch a live count in the table's corner, over four chat plans and twenty-eight features.
- Pro
Grouped Comparison Table Pricing
Comparison tablesA long comparison you fold by group: four API-gateway plans over thirty-four features in five groups, each group a header row you press to open, with one open at first and per-plan counts when closed.
- Pro
Feature Diff Pricing
Comparison tablesOne upgrade shown value by value: the price and call to action in one column, and in the other a ruled ledger with the Free limit struck through beside the Pro value on every row.
- Pro
Side by Side Pricing
Comparison tablesA before and after reveal: drag a handle across one photo editor to turn the Free version into the Pro version, with each half's price and button right under it.
- Pro
Two Plan Comparison Pricing
Comparison tablesSelf-hosted against cloud for a code host: two compact heads with their prices and buttons, over a nine-row matrix that marks the stronger side of each row.