shadcn.io is not affiliated with official shadcn/ui
Forum Thread Replies Features Block for React
A features section with a working forum thread: a post with an upvote toggle whose count follows your vote, and replies nested under an indent rail, each branch collapsing with its own button.
Installation
Overview
A forum thread feature section for React with Base UI, written for Hearthboard, a fictional community forum. The start side holds a compact header and three features (branches you can fold, votes that count once, replies that stay in context) in a plain list. The end side holds the thread itself in a hairline frame with + marks on its corners: a post by a member who runs a tool library, two replies and their own replies nested under an indent rail. Every upvote is a toggle button, and its count is derived: the stored number plus one when you have voted. Each top-level reply has a "Hide 2 replies" button that folds its branch; the button sits above the branch it controls, so nothing above it moves when it opens or closes. It's built from Toggle, Collapsible, Badge and Guides with your theme's tokens; a pressed vote is filled with the foreground colour, there is no call to action and nothing is in your primary colour. For community, Q&A and discussion products that want the thread to be the pitch.
FAQ
How do I change the thread?
The post is POST and the replies are REPLIES at the top of the file. Each reply has an author, initials, time, body, vote count and its own replies list, which the block renders one level deep. The reply count under the post is computed from the data, so it stays right when you add or remove one.
How do the votes work?
Each upvote is a Toggle. The component keeps the ids you have voted for in one list, and every count is the stored number plus one for a voted id, formatted with a fixed en-US number format so server and browser agree. Nothing is sent anywhere: wire vote to your API and keep the same shape.
How do the branches collapse?
Each top-level reply wraps its button and its nested replies in a Collapsible, open by default. The button's words change with its state ("Hide 2 replies" or "Show 2 replies") through the aria-expanded attribute, so there is no extra state. With reduced motion the height change is instant.
How do screen readers and keyboards handle it?
The heading is an h2, each feature is an h3 under it, and the post's title is an h3. Replies are nested lists, so the hierarchy is announced. Each vote button's name says what it votes for ("Upvote maria_k's post, 1,284") and is exposed as a pressed or unpressed toggle; each fold button is a real button with aria-expanded. Everything works with Tab, Enter and Space, with a visible focus ring.
Does it follow my theme?
Yes. The thread sits on bg-card, the indent rail is a hairline in your border colour, and a pressed vote takes bg-foreground with text-background, so it is dark on a light page and light on a dark one. The initials circles are outlined, not coloured.
How does it fit on a phone?
The header and the three features come first and the thread follows in one column. The nested replies keep their rail and indent at 320 pixels, long words wrap, and the buttons are the size of a thumb. The thread has no fixed height, so folding a branch just shortens the page.
Related
- Pro
Chat Conversation Thread Features
App screensA split features section for a support hand-off tool: three features in a ruled list beside a support thread drawn with a status card, a file, a reaction, a hand-off line and a typing indicator.
- Pro
Email Triage Inbox Features
App screensA working triage list for an email app: seven conversations with checkboxes, where ticking rows swaps the toolbar for a bulk bar in the same space, with E and Z shortcuts and per-row buttons on hover.
- Pro
Accordion FAQ Features
Tabs and accordionsA features section for an API gateway told as six capability questions in an accordion beside a sticky side header, each answer a sentence and a small drawing of the capability at work.
- Pro
Centered Activity Feed Hero
Stats and live dataA split hero with a live pill, a headline and two actions beside a ruled feed of recent activity, each row with an avatar, a name, an action and how long ago.
- Pro
Conversation Thread Testimonials
Chats and postsAn email-style thread for a tracing tool that turns a sceptic into an advocate, in a framed window beside a hairline divider: a subject line, earlier messages folded behind a disclosure row, the two latest open, and a Shine Button.
- Pro
Added Removed Diff List Features
App screensA unified diff of one config file in a hairline frame, with + and - gutters in foreground weights, one caption beside each hunk, folded runs of unchanged lines that open in place, and a footer counting the changes.