shadcn.io is not affiliated with official shadcn/ui
Stacked Cards About Block for React
Five engineering principles as a numbered list of toggle buttons beside a framed deck of five cards offset one behind another; pressing a principle brings its card to the front, each with the figure it is checked by.
Installation
Overview
A principles section for React with Base UI, written for Stackhollow, a fictional engineering handbook. A split on a solid divider: at the start, the heading and a numbered list of five principles as a vertical toggle group, one always pressed (pressing the pressed one keeps it); at the end, a framed deck of the same five cards stacked one behind another, each offset up and toward the end so its edges peek out. Pressing a principle moves its card to the front with a CSS transition on translate and z-index; the other cards turn inert and hidden from assistive technology, so only the front card is read, and a polite live region names the new one. Each card carries a title, a sentence and one figure the principle is checked by. On a phone the deck sits under the list. It's built from Guides and Toggle Group, with your theme's tokens for every colour; the pressed state is the foreground colour, never the primary. For engineering handbooks, culture pages and any set of principles that each deserve a card. The figures are example data.
FAQ
How do I change the principles?
Edit PRINCIPLES at the top of the file: each has an id, a title, a text, and a figure with the measure it counts. The list, the deck and the live region all read the same array, and the numbers come from the position. The deck's offsets assume at most five cards; more would need more entries in POSE.
How does the toggle group work?
It is the catalog's Toggle Group in vertical mode, so the arrow keys move between the principles and Tab leaves the list. One principle is always pressed: the group is built with multiple and a value of one, and pressing the pressed button is ignored, so it can never switch off. The group's props differ slightly between libraries (some use a set of keys, some a type), but the behaviour is the same on every target.
How is the deck read by a screen reader?
Only the front card is exposed: the other four are inert and aria-hidden, so they hold no tab stops and no text. The principles in the list are the controls, and a visually hidden live region announces "Principle 3 of 5" and its title when you press one. The offset edges are decoration.
How does it fit on a phone?
The list comes first, one principle per row, and the deck sits under a rule below it with smaller offsets so the front card keeps enough width at 320 pixels. In a right-to-left layout the cards peek out toward the end, which is the opposite side, and the numbers stay at the start of each row.
Related
- Pro
Principles Rail About
Principles and processA split about section for a release-management tool: a sticky title at the start, and six principles as stations on a hairline rail, each opening to what it means and how it shows up.
- Pro
Situation Tabs Operating Principles
Principles and processAn operating-principles section for an accounting-automation company: line tabs by situation, and under them the open situation's three rules as hairline rows, each with the question we ask.
- Pro
Do and Don't Design Principles
Principles and processA design-principles section for a design-system manager: four principles in cells, each with its test as a question and the same screen sketched done well and done badly.
- Pro
Philosophy About
StatementsA philosophy section for a meditation app: a heading and one pull quote that stays in view at the start, beside five numbered beliefs, each a short title and a paragraph, ruled from a solid divider to the rail.
- Pro
Layered Deck Shuffle Features
Carousels and mediaA stack of six flashcards with one large front card and three peek cards above it at shrinking scale; Next card sends the front card to the back and clicking a peek brings it forward, beside three features.
- Pro
Fanned Card Deck Features
Carousels and mediaFive playbook cards stacked and pivoting from their bottom edge that spread on an arc on hover, on focus inside the deck or when a Fan out toggle is pressed, each with a small drawing of its play.