Calm motion: animations on this site only fade, with no movement
Poll
One-question vote with results
A question with a few answers, and the results after a person votes. Use it for a quick check of opinion. For a long form with many questions, use Questionnaire.
Basic
- Tabs44% · 18 votes
- Spaces34% · 14 votes
- Either, if the formatter runs22% · 9 votes
- Before the vote, the poll is a radio group and a Vote button. The button waits for a choice.
v-modelholds the value that this person voted for. When it is set, or whenclosedis true, the poll shows the results. Set it from storage to show the results to a person who already voted.votefires with the value. The poll does not count votes. Your server counts them, and you pass the new totals inoptions[].votes. Votes include the vote of this person.- Each result shows the percent and the number of votes, as text. A screen reader gets the same text as the bars. The bar of your own vote takes the accent color, because color means chosen.
labelsreplaces the English words:vote,yours, andvotes(n)for the plural.
Usage
ts
import { BlessPoll } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
question* | string | — | |
options* | BlessPollOption[] | — | |
closed | boolean | — | no more votes: show the results to everyone |
labels | Partial<{ vote: string; yours: string; votes: (n: number) => string; }> | — | |
modelValue | string | — | the value this person voted for. Set it to show the results. |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: string | undefined] | |
vote | [value: string] |