nuxt-x-affiliate
Poll
Single-question poll with optional pre-vote results — POSTs vote to your endpoint.
Poll
The XAFPoll component renders a single-question poll with a list of options. After voting (or immediately if showResultsInitially is set), each option reveals a percentage bar. Vote is POSTed to your endpoint for tallying.
Components
<XAFPoll />
<XAFPoll
poll-id="keyboard-favorite-2026"
question="Which keyboard are you using most right now?"
endpoint="/api/polls/vote"
:options="[
{ id: 'mx', label: 'Logitech MX Keys', votes: 412 },
{ id: 'k3', label: 'Keychron K3', votes: 287 },
{ id: 'rk', label: 'Royal Kludge RK61', votes: 198 },
]"
/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
question | string | required | The poll question. |
options | PollOption[] | required | Each option: { id, label, votes? }. votes is the initial count for pre-existing tallies. |
endpoint | string | — | POST { pollId, optionId } here. |
pollId | string | — | Tracking ID for analytics. |
showResultsInitially | boolean | false | Reveal results before the user votes (e.g. for closed polls). |
Local optimistic tally increments the chosen option by 1 immediately so the UI is responsive before the endpoint round-trip.
AI Context
component: XAFPoll
package: "@xenterprises/nuxt-x-affiliate"
use-when: Single-question poll with optional pre-vote results, POSTs to endpoint for tallying.
