Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Reader Poll Blog Block for Ark UI

A reader poll in a split: a RadioGroup of four choices and a Vote button at the start, result bars with percentages, vote counts and a total at the end, and a Change vote button that takes your vote back.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A reader poll for React with Ark UI, written for Pollen Weekly, a beekeeping newsletter. A start-aligned header sits over a split behind a divider. At the start is the question with four choices, a RadioGroup of cells on shared hairlines, and a Vote Shine Button. At the end are the results: the same four rows, empty until you vote, then a bar, a percentage and a vote count each, your vote counted in, and the total. Change vote takes your vote back, so a vote moves a count by one and back. On a phone the results sit under the question. The 612 earlier votes are example data, and your vote stays in the page. It is built from Guides, RadioGroup, Field, Progress, Button and a Shine Button. For newsletters, blogs and any page that asks its readers one question.

FAQ

Are the votes real?

No. The 612 votes before yours are example data, and the page says so under the results. Your vote is held in the page and is gone on reload. To make it real, send the choice in the vote handler and replace votes in OPTIONS with the counts your server returns.

How are the percentages worked out?

From the votes shown, with whole numbers that always add to 100: each share is rounded down and the leftover points go to the largest fractions (sharesOf). Add or change an option and every percentage, bar and the total follow, because nothing is typed in twice.

What does Change vote do?

It removes your vote, so the choice you made counts one less, the results empty again and the choices unlock. Focus returns to the first choice. Voting adds one to exactly one option, so you can vote, look, take it back and choose differently as often as you like.

What if I press Vote with nothing chosen?

The form says so in a line that is always in the layout ("Choose one of the four before you vote.") and moves focus to the choices; nothing is counted. The Vote button stays enabled for this reason, so the message is reachable by keyboard.

Does it work right to left?

Yes. The split, the radios and the bars follow the page direction, and the percentages and counts are isolated with bdi.