Poll Vote

A one-tap poll where bars race to their shares as totals count up.

Preview

"use client";

import { PollVote } from "@/components/motion/poll-vote";

const OPTIONS = [
  { id: "springs", label: "Springs", votes: 42 },
  { id: "curves", label: "Easing curves", votes: 27 },
  { id: "both", label: "Both, it depends", votes: 31 },
];

export function PollVoteUsage() {
  return (
    <div className="w-72">
      <PollVote options={OPTIONS} />
    </div>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/poll-vote

API Reference

options
PollOption[]

The choices, each with an id, label and vote count before the viewer's vote.

Default—
value?
string | null

The viewer's choice, or null before they vote.

Default—
defaultValue?
string | null

The initial choice when uncontrolled. Default: null

Defaultnull
onValueChange?
((value: string | null) => void)

Called with the option id when the viewer votes or changes their vote.

Default—
labels?
Partial<{ poll: string; percent: string; voted: string; votes: string; }>

Override any built-in string, e.g. for translation.

Default—
sound?
boolean

Play a crisp select on a vote. Off by default; a `SoundProvider` can mute it app-wide.

Defaultfalse
className?
string

Classes merged onto the root fieldset.

Default—

Updated