shadcn.io is not affiliated with official shadcn/ui
Variant Matrix Gallery Block for React
A native table of drawn mugs by glaze and size, where hovering or focusing a cell lights its row and column heads and the cells between them, and choosing a cell writes its stock in a status line that keeps its height.
Installation
Overview
A variant matrix for React with Base UI. A centred header sits over one native table, rail to rail: three glaze rows (Graphite, Stone, Bone) by four size columns (S to XL), every cell a drawn mug at its size and in its glaze with the stock under it in words. Hover a cell or tab to it and the row head and column head light up, and so do the other cells in that row and column, which shows exactly what you are choosing. Choosing a cell writes "Stone, L, 12 oz: in stock" in a polite status line under the table. Row heads are th scope="row" and column heads th scope="col"; on a phone the table scrolls sideways while the glaze names stay in view. The mugs are drawn in the theme's greys. It's built from Guides and a native table. For product pages with two options and any grid where rows and columns both mean something.
FAQ
Why a real table?
Two axes are a table's job: a screen reader announces the glaze and the size for every cell, the caption names the matrix, and the scope attributes tie each cell to its heads. The table is a native one on every base, with the cells as buttons.
What lights up when I point at a cell?
The row head and the column head take a darker solid tone, and the other cells in that row and column take a lighter one. It follows the pointer and keyboard focus alike, and clears when either leaves.
What does choosing a cell do?
It marks the cell aria-pressed and writes its glaze, size, ounces and stock into the status line. Nothing is sent anywhere; hook the choice to your cart. The stock figures are example data.
Which keys work?
Tab visits the cells in reading order, row by row. Enter or Space chooses. When the table is wider than its frame, the frame itself takes focus so the arrow keys can scroll it.
How do I use my own photographs?
The drawn pictures are one Scene component. Where the code comment says so, replace it with an <img> (object-cover in a box of the picture's own ratio) and give each entry a src. Keep each entry's ratio the photograph's own so the layout doesn't change. The mugs are the mug scene, sized by a number from 0 to 1; with photographs, scale each in its cell the same way.
Related
- Pro
Product Showcase Gallery
Stage and thumbnailsA product viewer for a running shoe: a vertical rail of four angles beside a 4:3 stage, three finishes that recolour every picture, and price, sizes and stock with an Add to bag button.
- Pro
Paginated Minimal Grid Gallery
Hairline gridsA quiet grid of twenty-four drawn concrete-architecture plates, eight to a page on shared hairlines, with a title and year that appear on hover and focus and the catalog pagination in a band that ends the block.
- Pro
Inline Expansion Thumbnail Grid
Hairline gridsSixteen drawn thumbnails on shared hairlines, eight across, where choosing one opens a preview band straight under its row with the whole picture, its source, Previous, Next and Close, without changing the block's height.
- Pro
Split View Gallery
Stage and thumbnailsAn asset-review split: a listbox of eight files with small drawings at the start, the chosen file's preview and details at the end, and a divider you drag or arrow to resize.
- 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
Before After Toggle Features
Live controlsA Before and After control that cross-fades a settings screen between a cluttered version (warning banners, a nested menu, badges everywhere) and a clean one, in a frame that never changes height.