Components
Poll
Vote and see the results animate in.
<Poll question="Tabs or spaces?" options={["Tabs", "Spaces"]} votes={votes} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/poll.jsonimport { Poll } from "@/components/poll"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Vote, then see the results: bars grow to each option's share, and your own choice is marked and counted. The results are announced when they appear.
import { Poll } from "@/components/poll";
export function WeeklyPoll({ votes }: { votes: number[] }) {
return <Poll question="Tabs or spaces?" options={["Tabs", "Spaces"]} votes={votes} onVote={(i) => sendVote(i)} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
question | string | The question. | |
options | string[] | The choices. | |
votes | number[] | all 0 | Existing votes per option. |
onVote | (index: number) => void | Called with the chosen option. | |
className | string | Classes for the wrapper. |
With reduced motion, the result bars appear at full length without growing.