shadcn.io is not affiliated with official shadcn/ui
Baseline Comparison Table Block for React
Five camera bodies compared against one you pick: every figure shows its own value and, under it, a signed difference or Same or Different against the baseline, with sticky spec names and grouped rows.
Installation
Overview
Show what separates things by how far they are from the one you know, with this baseline comparison table for React with Base UI. A compact header names the range, and a hairline frame with a plus mark on each corner opens with a band: "Compare against" and a Select of five camera bodies, with a polite line that says which one is the baseline. Under it a native table has the specs down the side and the bodies across, grouped under rows for image, video, body and price. Each figure shows its value and, under it, how it stands against the baseline: a number says how much more or less ("-60 shots", "+120 g") with an arrow, a word says "Same" or "Different", and the baseline's own column says "Baseline" and is tinted. Choosing another body re-reckons every line without moving a column, so the table never changes height. The spec names and group names stay in view while the table scrolls sideways. It's built from Select, Badge and Guides, with a CSS entrance only. For product ranges, plan tiers and any set of things people judge against a reference.
FAQ
How do I use my own specs?
Edit BODIES and GROUPS. A spec gives either numbers (one figure per body, in the bodies' order, with its unit written for one and for many, or money for a price) or words (one word per body). figureOf, relationOf and trendOf draw the first and second lines from them and the baseline, so adding a spec is one entry. Differences are derived, never typed, so they can't drift from the figures.
How are the differences worked out?
A number is compared with the baseline's: the gap is shown with its sign and unit ("+12 MP", "-90 g", "-$900") and an arrow that points up or down, or "Same" with an equals sign when it is zero. A word is "Same" when it matches the baseline's and "Different" when it doesn't. The baseline's own cells say "Baseline". Nothing is coloured: direction is an arrow, a sign and a word, so it reads in any theme and without colour.
How does a screen reader get the comparison?
Each second line carries a hidden phrase after the visible one ("+12 MP", then "more than Grove 33"), so the sign and arrow don't have to be guessed. The table has a caption that names the baseline, the spec name is each row's header and each body's name is its column header. The polite line says which body is the baseline whenever it changes.
How does it look on a phone?
The band stacks, with the menu full width, and the table scrolls sideways inside its labelled, focusable region while the spec names stay pinned at the start, so a figure is never separated from its name. Group names stay in view too. The page itself never scrolls sideways.
Does the table change height when the baseline changes?
No. Every cell has two lines, a value and a relation, so a cell is the same size whichever body is the baseline, and the baseline badge in the heads is always drawn, hidden on the others, so the head doesn't change either. Only the tint and the second lines change.
Related
- Pro
Pinned Columns Table
Columns and pagingA vehicle log of ten columns whose first and last stay pinned while the rest scroll under them, with a shadow that appears only when there is something to scroll under and a switch that turns the pins off.
- Pro
Sticky Header Table
Columns and pagingA sixty-row cash ledger in a fixed-height region where the column heads and the day row stay at the top while you scroll, with a Jump to menu of weeks that scrolls the region and a band that names the day at the top.
- Pro
Version Comparison Matrix Changelog
Filters and browsingA framed feature table across three versions with a check, a half circle or a dash in each cell, grouped by category, and an Only what changed switch that keeps the height.
- Pro
Compare Tray Pricing
Comparison tablesA 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.
- Pro
Grouped Competitor Table About
ComparisonsA grouped comparison for an ETL tool: sixteen features in Core, Security and Support, a toggle that rings one vendor column, and a note on the rows that need one.
- Pro
Compare Rows Table
Totals and comparisonA sales table where you tick up to two quarters and a band closing the panel compares them metric by metric, with the signed difference and the change as an arrow, a sign and a word, plus Swap A and B.