Battle of Fans

A head-to-head fan vote between football teams or football players. While voting is open it shows a countdown, the two sides with a Vote button each, and the vote split; once voting ends it announces the winner (or a draw) with the final result. Optionally shows the match odds under the card.

Import

import { BattleOfFans } from "fansunited-frontend-components";
import { BattleOfFansProps } from "fansunited-frontend-core";

Setting up the poll

A Battle of Fans is a poll with the type battle-of-fans:

Poll fieldWhat it holds
context.tagsThe competing football teams (team) or players (player), e.g. fb:t:8205 and fb:t:889.
optionsOne option per side, in the same order as the tags. The first option and tag are the home side.
custom_fields.voting_ends_atWhen voting closes, in ISO 8601 UTC, e.g. "2026-12-01T20:00:00Z".
custom_fields.voting_starts_atOptional. When voting opens, in ISO 8601 UTC, for a poll that is INACTIVE until a scheduled task activates it.

Voting also closes when the poll is no longer ACTIVE. Each user votes once.

While the poll is INACTIVE and voting_starts_at is ahead, the battle shows the sides with disabled Vote buttons and counts down to the start. Once the start time passes, it shows "Voting starts soon" and reads the poll again every 15 seconds until it is ACTIVE. If the poll is still INACTIVE 5 minutes after the start time, it shows as ended. Poll management writes both custom fields from the poll's scheduled tasks.

Names, logos, headshots and colours come from the tagged entities: a team uses its own branding colours, a player uses their club's. Sides without usable colours fall back to the theme, and a team without a logo shows its initials.

Required props

PropTypeDescription
entityIdstringPoll ID of a battle-of-fans poll.
sdkFansUnitedSDKModelSDK instance.
languageLanguageTypeDisplay language.

Optional props

PropTypeDescription
themeOptionsCustomThemeOptionsSee Theming.
progressDisplay"bar" | "background""bar" shows the split as a progress bar under the sides; "background" makes the sides' background the meter, with the percentages inside each side. Defaults to "bar".
showResultsBeforeVotebooleanShow the split before the visitor votes. When false, it stays hidden until they vote or voting ends. Defaults to true.
showTrophybooleanShow the trophy badge on the winner's image. Defaults to true.
trophyPosition"top-left" | "top-right" | "bottom-left" | "bottom-right"Corner of the winner's image the badge sits on. Stays on that corner in right-to-left languages. Defaults to "bottom-right".
labelsBattleOfFansLabelsOverride any text. See Labels.
showOddsbooleanShow the match odds under the card. Only for a battle between two teams with odds.eventId set. Defaults to false.
oddsBattleOfFansOddsConfigOddsConfig plus eventId, the match the prices are for. See Odds.
userIsLoggedInbooleanWhether the current visitor is signed in. Drives the sign-in gate of a poll with authRequirement: "REGISTERED".
signInCTASignInCTADetailsShown in place of the Vote buttons while the sign-in gate is active. See Sign-in CTA.
leadsLeadsOptionsThe lead form of a poll with authRequirement: "LEAD". position: "before" shows it before voting; "after" shows it once the visitor picks a side, and the vote is cast after the form. Without position there is no form. See Lead Collection.
callbacksBattleOfFansCallbacksonFinish(vote) runs after a vote is cast, with the vote the API returned. It does not run for a visitor who had already voted.
disableCachebooleanBypass the CDN cache for every request.

States

The widget picks its view from the poll — there's no prop to force one — and keeps the same height in every state:

StateView
Voting openCountdown, both sides with a Vote button in the side's colour, and the split (or "Vote to see the results").
VotedThe chosen side shows "Thank you"; the other side turns neutral. The split stays visible. A returning visitor who has voted lands here.
Ended, winner"Voting has ended". The winner's colour takes over most of the card, with the trophy badge; the other side is greyed out.
Ended, drawAn exactly even split: both sides stay equal, with "The fans are evenly split."
Lead formA poll with authRequirement: "LEAD" and leads.position set: the form takes the sides' place, with the competing sides (or the picked one, in the side's colour) and the poll's lead title and description. A visitor who has already voted, or a poll that has ended, skips it.

When the countdown reaches zero the widget switches to the ended view without a reload.

With more than two tagged sides the same layout extends to one column per side; on narrow screens the sides stack as rows.

Odds

interface BattleOfFansOddsConfig extends OddsConfig {
  eventId?: string;
}

eventId is the match, e.g. "fb:m:12345"; every other field (market, mode, operators, affiliate ids…) works as in Odds. The strip shows only when the odds API returns prices for that match.

Labels

Every user-facing string falls back to the locale bundle and can be overridden per key through labels:

<BattleOfFans
  entityId="your-poll-id"
  sdk={sdk}
  language="en"
  labels={{
    title: "Derby day",
    subtitle: "Who's your team?",
    vote: "Pick",
  }}
/>

Keys: title, subtitle, votingEndsIn, votingStartsIn, votingStartsSoon, days, hours, minutes, seconds, vote, thankYou, voteToSeeResults, votingEnded, endedSubtitle, drawSubtitle, winner, ofTheVotes, finalResult. title and subtitle default to the poll's own title and description; when the poll has none, the default subtitle differs for teams and players.

Examples

Basic

import { BattleOfFans } from "fansunited-frontend-components";

<BattleOfFans entityId="your-poll-id" sdk={sdk} language="en" />;

Background fill, results after the vote

<BattleOfFans
  entityId="your-poll-id"
  sdk={sdk}
  language="en"
  progressDisplay="background"
  showResultsBeforeVote={false}
/>;

With match odds

<BattleOfFans
  entityId="your-poll-id"
  sdk={sdk}
  language="en"
  showOdds
  odds={{ eventId: "fb:m:12345", operators: ["betano-bg"] }}
/>;

Sign-in required before voting

<BattleOfFans
  entityId="your-poll-id"
  sdk={sdk}
  language="en"
  userIsLoggedIn={false}
  signInCTA={{
    defaultLabel: "Sign in to vote",
    onClick: () => {
      // Handle sign-in logic
    },
  }}
  callbacks={{ onFinish: (vote) => console.log("Voted for", vote.optionId) }}
/>;

Did this page help you?