component
Poll
A question with vote bars, single or multiple choice.
Install
npx shadcn@latest add https://whatsapp-components.crafter.run/r/poll.jsonWrites 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.
| Prop | Type | Default |
|---|---|---|
optionsrequired | PollOption[] | — |
questionrequired | string | — |
className | string | — |
labelsLabels, so the component can speak another language. | { single?: string; multiple?: string; votes?: (n: number) => string; } | — |
multiple | boolean | false |
onSelect | (option: PollOption) => void | — |
totalVotesOverrides 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