Özer

Poll Results

Component 29

About

An interactive poll where clicking an option reveals animated result bars, vote percentages, and the winning choice.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Poll Results to your project and fits it to your theme.

Code

How Poll Results is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { PollResults, type PollOption } from "@/components/ui/poll-results";
import { useState } from "react";

const SEED: PollOption[] = [
  { id: "oak", label: "Oak, oiled", votes: 54 },
  { id: "travertine", label: "Travertine", votes: 41 },
  { id: "brick", label: "Painted brick", votes: 17 },
  { id: "concrete", label: "Concrete, sealed", votes: 9 },
];

export function PollResultsDemo() {
  const [options, setOptions] = useState(SEED);

  return (
    <div className="mx-auto w-full max-w-[340px]">
      <PollResults
        label="Floor for the front room?"
        options={options}
        onVote={(id) =>
          setOptions((prev) =>
            prev.map((o) => (o.id === id ? { ...o, votes: o.votes + 1 } : o)),
          )
        }
      />
    </div>
  );
}

export default PollResultsDemo;

Dependencies

More by Özer

View all
  • Password Strength

    Password Strength

    1.3K
  • OTP Input

    OTP Input

    824
  • Loading Button

    Loading Button

    617
  • Progress Bar

    Progress Bar

    594
  • Reorder List

    Reorder List

    318
  • Task Steps

    Task Steps

    284
  • Hold to Confirm

    Hold to Confirm

    255
  • Reading Progress

    Reading Progress

    174

Explore more

Part of interior.dev — browse the full library on 21st.dev.