Poll
ProNewA supplied-data poll that becomes its own results: single or multiple choice, image options, colored appearances and exact percentages and vote counts.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| question* | stringThe question, rendered as the poll's heading. | — |
| options* | PollOption[] | — |
| description | stringA line of supporting text under the question. | — |
| multiple | booleanLet people tick several options and confirm with a Vote button. Single choice votes on the first press. | false |
| max | numberWith `multiple`, the most options one person may tick. | — |
| appearance | "card" | "plain" | "gradient"`card` sits on the card token, `plain` has no surface, `gradient` paints the two `gradient` colors behind white text. | "card" |
| accent | stringAny CSS color. Tints the options, the result bars and the chosen outline. | "#1672f3" |
| gradient | [string, string]Top and bottom colors of the `gradient` appearance. | ["#94006d", "#3d48e4"] |
| defaultVoted | string[]Option ids this visitor has voted for before, already included in `votes`. Starts the poll on its results. | — |
| onVote | (ids: string[]) => void | Promise<unknown>Called with the chosen ids. Return a promise to show the pending state; reject it to show the error and let them retry. | — |
| allowChange | booleanOffer “Change vote” under the results. | false |
| showCounts | booleanShow each option's vote count next to its label in the results. | true |
| closed | booleanVoting has ended: results only, nothing to press. | false |
| loading | booleanShow placeholder rows while the options load. | false |
| locale | stringLocale for grouping digits in vote counts. | "en-US" |
| className | string | — |
Accessibility
- Options are real buttons grouped under the question; multiple choice exposes them as checkboxes with a Vote button.
- After voting, focus moves to the results list and a live region reads every share; each row reads as “350 votes, 35%, your vote”.
- Your choice is marked with an outline and a check, never by color alone.
- A failed vote is announced as an alert and the options stay ready to retry.
- Result bars use transform-only fills and numbers update without a React re-render per frame; both appear at their final value under reduced motion.