X Enterprises
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

PropTypeDefaultDescription
questionstringrequiredThe poll question.
optionsPollOption[]requiredEach option: { id, label, votes? }. votes is the initial count for pre-existing tallies.
endpointstringPOST { pollId, optionId } here.
pollIdstringTracking ID for analytics.
showResultsInitiallybooleanfalseReveal 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.
Copyright © 2026