shadcn.io is not affiliated with official shadcn/ui
Round Tabs Debate Blog Block for React
A two-sided debate in three round tabs, For and Against side by side with a writer, an argument and three key points each, and a reader poll that moves by one and back.
Installation
Overview
A debate block for React with Base UI, written for the Touchline Ledger, a sports-analysis site, on the question "Is the high press ruining the league?". A start-aligned header sits over an underline tab band with three rounds: Opening, Rebuttal and Closing. In each round two arguments stand side by side on a split divider, For at the start and Against at the end, each under a typographic cover that sets its word large, with the writer's initials and role, an argument title and three key points. Under the tabs, a band shows where readers landed as a two-part bar worked out from example vote counts, and two toggle buttons let you take a side: your vote adds one to that side, pressing it again takes it back, and the other button moves it across. Every round is drawn once more, unseen, in the same grid cell, so the block never changes height. It's built from Tabs, Toggle Group, Progress, Avatar and Guides. For sports and politics blogs, product trade-off posts and any opinion piece with two committed sides. The vote is kept on the page and lost on reload; the counts are example data.
FAQ
How do I change the debate?
Edit OPENING, REBUTTAL and CLOSING at the top of the file. Each round has a pro and a con argument (a title and three points), and WRITERS holds the two writers' names, roles and the word each cover sets. BASE_VOTES holds the example counts before a reader votes: replace them with your own numbers, or send the vote to your server in choose.
How does the poll move by one and back?
The two vote buttons are a single-choice toggle group that may be empty. Pressing one adds one to its side; pressing the pressed one takes it back; pressing the other moves your vote across. The shares are worked out from the two counts, the first rounded and the second what remains, so they always add to 100, and the bar, the counts and the percentages all come from the same numbers. A polite status line says what changed.
Why does the block not change height when I switch rounds?
Each round is drawn twice. The live round sits in a grid cell, and an unseen copy of all three (hidden from assistive technology and the keyboard) sits in the same cell, so the cell is as tall as the tallest round. Switching only changes what shows on top.
How does it work with a keyboard and a screen reader?
The tabs are a labelled tab list: Tab reaches the selected tab, the arrow keys move between rounds, and Home and End jump to the first and last. The two arguments are a list under the round's name, each with its writer, a heading and three points. The vote buttons are a labelled toggle group: Tab reaches it, the arrows move between the two buttons and Space or Enter presses one. The bar is decoration; the counts and percentages are text.
Related
- Pro
Select Pair Comparison Blog
Story formatsTwo Selects pick two of five posts and the posts stand in two columns on a split divider, with Length, Level, Topics, Updated and Takeaway rows that line up and a line saying how many rows differ.
- Pro
Q and A Interview Blog
Story formatsAn interview told in four question-and-answer bands: the host's question at the start, the guest's answer at the end, both speakers' initials avatars in the header, and one phrase marked with a highlighter.
- Pro
Margin Note Editorial Blog
Featured storyThree editor's picks as split rows: the post with a numeral tile at the start and, in a tinted margin cell at the end, the editor's note with a hanging quote mark and a marked reason.
- Pro
Tabs Layout Blog
Post listsA film-criticism reading list with three underline tabs, Latest, Popular and Editor's picks, each drawing a different row: dated rows, ranked rows with read counts, and rows with an editor's note.
- Pro
Segmented Bar Recap Blog
Post listsA product team's weekly recap as five numbered posts under one segmented bar whose segments are as long as each post's reading time; pointing at a row lights its segment.
- Pro
Categorized FAQ
Topics and filtersA topic-tabbed FAQ for a bookkeeping app: a compact header, a band of line tabs with a count on each, and one accordion per topic.