Ballmac UI home

Poll 1: vote and live results

A poll: pick one option or several, vote, and results appear with each share, the leader marked and your choice highlighted. Your vote counts at once and is taken back with the reason if it fails; change it until the poll closes.

State

The normal view. Pick a state to see what the block shows while it loads, is empty or fails.

Open in v0 (opens in a new tab)

Installation

$ pnpm dlx shadcn@latest add @ballmac/poll-1

Usage

Example: poll-1-demo.tsx
"use client"

import { Poll1 } from "@/components/ballmac/blocks/poll-1/poll-1"

export default function Poll1Demo() {
  return <Poll1 onVote={() => new Promise((r) => setTimeout(r, 600))} />
}

States

Pass state and the block does the rest: skeletons that match its layout, a clear empty message, an error you can retry, and announcements for screen readers.

  • Loading

    A skeleton question and options, announced as loading.

    state="loading"
  • No poll

    Says a question appears here when there is one to vote on; emptyState sets the copy.

    state="empty" (or options={[]})
  • Could not load

    An alert saying your vote has not been lost, with Try again (onRetry). A vote that fails to save is taken back with its reason in place.

    state="error"

Quality scorecard

8/8

Every applicable check passes

Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 7 examples.

How we measure
  • Passed: Accessibility scan

    No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).

  • Passed: Small screens

    No sideways scrolling at 360, 390 or 1280 px wide.

  • Passed: Reduced motion

    Every endless animation stops when the visitor asks for less motion.

  • Passed: Right to left

    Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).

  • Passed: Clean console

    No console errors or React hydration errors while loading.

  • Passed: Keyboard

    9 tab stops, each showing a visible change when it takes focus. 3 documented keys.

  • Passed: Loading, empty and error

    Ships loading, empty, error states, each with an example.

  • Passed: Automated tests

    Covered by poll-1.test.tsx.

  • For information: Footprint

    4.2 KB of source (gzip) in 1 file. Installs lucide-react.

Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.

Dependencies

Use with AI

A poll. <Poll1 question description options={[{ id, label, votes, hint }]} multiple maxChoices={2} closesAt='2026-10-20T18:00:00Z' now='2026-10-18T10:00:00Z' defaultVoted={['a']} onVote={(ids) => Promise} />. Before voting people choose (radio buttons, or checkboxes with multiple); after voting, or when closed, they see each share, the single leader and their own choice. Votes are counted at once; reject onVote and they are taken back with the message. Changing a vote removes the old choice and adds the new. Time left comes from closesAt and now; pass now yourself, the block never reads the clock. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Poll 1: vote and live results (@ballmac/poll-1) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Letting users vote on what to build next
  • Community and event polls with live results

Not for

  • A multi-question survey (use survey-1)
  • Scored questions with right answers (use quiz-1)

Registry JSON: https://ui.ballmac.com/r/poll-1.json

Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.