Skip to content
caliper ui pro docs

Poll

A question with a few answers. Before voting the answers are a plain list of buttons; choosing one reveals the results, each bar growing to its share, your vote ticked and the leader in bold, with Change vote to take it back.

Pro

Where should we go in March?

22 votes· Closes Friday

When to use

  • Quick decisions in a team space: an offsite, a release name, a meeting time.
  • Community posts where seeing others' answers is the point.

When not to use

  • Forms where the answer must be validated or stored per person; use radio buttons.
  • Ranking or many questions; use a survey.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/poll

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

API reference

Poll

7 props

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
question *string—
options *readonly PollOption[]—
votestring | null—The option this reader chose. Leave out to let the poll keep its own vote.
defaultVotestring | nullnull
onVote((option: string | null) => void)—Called with the new choice, or null when the reader takes their vote back.
closedbooleanfalseNo more voting: the results show to everyone.
notestring—A line under the results, e.g. "Closes Friday".

Keyboard

  • No custom key handling; Tab and the native activation keys do the work.

Accessibility

It is built on native elements and keeps aria-labelledby, aria-hidden, aria-label and aria-live in step with state. Changes that matter are announced through a live region.

Notes for AI

Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.

/docs/components/poll.md

The index of every part is at /llms.txt.

More in Choice groups