Browse components

component

Poll

A question with vote bars, single or multiple choice.

Install

npx shadcn@latest add https://whatsapp-components.crafter.run/r/poll.json

Writes 5 files into your project, and installs clsx and tailwind-merge.

Preview

¿Qué aroma lanzamos primero?Elige una80 votos
demos/poll.tsx
import { MessageBubble } from "@/registry/whatsapp/message-bubble";
import { MessageMeta } from "@/registry/whatsapp/message-meta";
import { Poll } from "@/registry/whatsapp/poll";

export default function Demo() {
  return (
    <MessageBubble
      direction="in"
      meta={<MessageMeta timestamp={new Date(2025, 0, 6, 9, 30)} />}
    >
      <Poll
        question="¿Qué aroma lanzamos primero?"
        options={[
          { id: "a", label: "Violeta nocturna", votes: 42 },
          { id: "b", label: "Cítrico andino", votes: 27, votedByMe: true },
          { id: "c", label: "Madera húmeda", votes: 11 },
        ]}
        labels={{ single: "Elige una", votes: (n) => `${n} votos` }}
      />
    </MessageBubble>
  );
}

Props

Read from PollProps in the component source at build time.

PollProps
PropTypeDefault
optionsrequiredPollOption[]—
questionrequiredstring—
classNamestring—
labels

Labels, so the component can speak another language.

{ single?: string; multiple?: string; votes?: (n: number) => string; }—
multiplebooleanfalse
onSelect(option: PollOption) => void—
totalVotes

Overrides the sum of per-option votes.

number—

Files

  • registry/whatsapp/poll.tsx
  • registry/whatsapp/types.ts
  • registry/whatsapp/cn.ts
  • registry/whatsapp/whatsapp.css
  • LICENSE