Skip to content

Wheel of Fortune

Flagship spin-to-win component with physics-based animation and fairness UX.

10025.6%
20020.5%
50012.8%
10007.7%
JACKPOT2.6%
5030.8%

Odds displayed before each spin. Results are randomly determined.

Features

  • Physics-based animation — Realistic deceleration with customizable easing
  • Weighted segments — Configure win probability per segment
  • Fairness UX — Optional probability display before spin
  • Accessible — Screen reader announcements, keyboard control
  • Reduced motion — Respects prefers-reduced-motion
  • Mobile optimized — Touch-friendly, responsive sizing

Usage

vue
<script setup>
import { FkWheel } from '@fortune-kit/components'

const segments = [
  { id: '1', label: '100', value: 100, weight: 10, color: '#22c55e' },
  { id: '2', label: '500', value: 500, weight: 5, color: '#3b82f6' },
  { id: '3', label: 'JACKPOT', value: 5000, weight: 1, color: '#ef4444' }
]

function handleResult(segment) {
  console.log('Winner:', segment)
}
</script>

<template>
  <FkWheel
    :segments="segments"
    :size="320"
    show-probability
    @spin-end="handleResult"
  />
</template>

Props

PropTypeDefaultDescription
segmentsWheelSegment[]RequiredArray of wheel segments
sizenumber320Wheel diameter in pixels
spinDurationnumber4000Spin animation duration (ms)
disabledbooleanfalseDisable spinning
showProbabilitybooleanfalseShow odds before spin
reduceMotionbooleanfalseForce reduced motion mode
mode'local' | 'server''local'Result determination mode

Segment Type

ts
interface WheelSegment {
  id: string
  label: string
  value: number | string
  weight?: number  // Higher = more likely (default: 1)
  color?: string   // Segment color
}

Events

EventPayloadDescription
spinStartEmitted when spin begins
spinEndWheelSegmentEmitted with winning segment
clickEmitted when spin button clicked

Accessibility

  • Keyboard: Space or Enter to spin
  • Screen reader announces result after spin
  • Respects prefers-reduced-motion system setting
  • High contrast segment colors

Fairness UX

Enable show-probability to display odds before each spin. This builds trust by being transparent about win chances.

vue
<FkWheel :segments="segments" show-probability />

Each segment shows its percentage based on weight calculation.

Server Mode

For production use, you often want the server to determine the result for security and fairness. Use mode="server" to spin the wheel indefinitely until you provide a result from your backend.

vue
<script setup>
import { ref } from 'vue'
import { FkWheel } from '@fortune-kit/components'

const wheelRef = ref()
const segments = [
  { id: 'prize-100', label: '100', value: 100 },
  { id: 'prize-500', label: '500', value: 500 },
  { id: 'jackpot', label: 'JACKPOT', value: 5000 }
]

async function handleSpinStart() {
  // Wheel starts spinning, fetch result from server
  const response = await fetch('/api/spin')
  const { segmentId } = await response.json()

  // Set the result - wheel will slow down and stop on this segment
  wheelRef.value.setResult(segmentId)
}

function handleSpinEnd(segment) {
  console.log('Winner:', segment)
}
</script>

<template>
  <FkWheel
    ref="wheelRef"
    :segments="segments"
    mode="server"
    @spin-start="handleSpinStart"
    @spin-end="handleSpinEnd"
  />
</template>

Exposed Methods (Server Mode)

Access these via template ref:

MethodDescription
setResult(segmentId: string)Stop wheel on specified segment
isWaitingForResultComputedRef<boolean> - true while waiting for result
reset()Reset wheel to initial state

How It Works

  1. User clicks Spin - wheel starts continuous rotation
  2. @spin-start event fires - you call your API
  3. Wheel displays "Waiting..." and keeps spinning
  4. When API responds, call wheelRef.value.setResult('segment-id')
  5. Wheel decelerates and stops on the target segment
  6. @spin-end event fires with the winning segment

Built for iGaming with Vue 3