Skip to Content
zjkm-ui
Components

Poll

Vote and see the results animate in.

Tabs or spaces?
Props
<Poll question="Tabs or spaces?" options={["Tabs", "Spaces"]} votes={votes} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/poll.json
import { 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

PropTypeDefaultDescription
questionstringThe question.
optionsstring[]The choices.
votesnumber[]all 0Existing votes per option.
onVote(index: number) => voidCalled with the chosen option.
classNamestringClasses for the wrapper.

With reduced motion, the result bars appear at full length without growing.

On this page