A reusable and customizable Vue 3 component to spin a wheel of fortune โ perfect for games, giveaways, raffles, or any luck-based mechanic.
โจ Built with โค๏ธ, Vue 3, TypeScript & Tailwind CSS
- ๐ฏ Fully interactive โ Spin the wheel with a button or programmatically
- ๐ Optional user controls โ Let users edit segment values and colors directly in the UI
- ๐ Optional winner display โ Automatically shows the selected segment after spinning
- ๐ฑ Optional spin button โ Display a built-in "SPIN!" button or trigger manually
- ๐จ Custom or preset segments โ Provide your own segments or use built-in presets like:
- Fibonacci
- T-shirt sizes (S, M, L, XLโฆ)
- Yes/No/Maybe
- ...
pnpm add vue-roue
# or
npm install vue-roue<!-- App.vue -->
<script setup lang="ts">
import { ref } from "vue"
import "vue-roue/style.css"
import VueRoue from "vue-roue"
const segments = [
{ name: "๐ฑ Cat", color: "#f87171" },
{ name: "๐ถ Dog", color: "#60a5fa" },
{ name: "๐ Chicken", color: "#34d399" }
]
// Or use included preset
import { lunch } from "vue-roue"
const segments = lunch
const wheelRef = ref()
// To spin the wheel programmatically
const spin = () => wheelRef.value?.spin()
const handleWinner = (value: string) => {
console.log("Winner is:", value)
}
</script>
<template>
<Roue
ref="wheelRef"
:segments="segments"
:wheel-size="450"
with-spin-button
with-winner-display
with-controls
@winner="handleWinner"
/>
</template>| Prop | Type | Default | Description |
|---|---|---|---|
segments |
Segment[] |
โ | Required. List of segments to spin. |
wheelSize |
number |
600 |
Size of the wheel in pixels. |
withSpinButton |
boolean |
false |
Show a "SPIN" button under the wheel. |
withWinnerDisplay |
boolean |
false |
Show the winner name below the wheel. |
withControls |
boolean |
false |
Show segment editing UI below the wheel. |
Call
spin()programmatically usingref:
const wheelRef = ref()
wheelRef.value?.spin()| Event | Payload | Description |
|---|---|---|
winner |
string |
Emitted when a segment wins. |
type HexColor = `#${string}`
type Segment = {
name: string
color?: HexColor
}| Name | Description | Values |
|---|---|---|
fibonacci |
Estimation using Fibonacci | 0, 1, 2, 3, 5, 8, 13, 20, โ, โ |
tshirts |
T-shirt sizing scale | XS, S, M, L, XL |
yesNoMaybe |
Simple decision options | Yes, No, Maybe |
dice |
Simulates a 6-sided dice | 1, 2, 3, 4, 5, 6 |
nightActivity |
Evening activity suggestions | ๐บ TV show, ๐ฅ Movie, ๐ฎ Video game, โ๏ธ Board game, ๐ Book, ๐ค Sleep |
lunch |
Lunch ideas | ๐ Pizza, ๐ฅ Salad, ๐ฅซ Soup, ๐ Burger, ๐ฏ Burrito, ๐ฃ Shushi, ๐ Pasta |
Clone the repo and run locally:
pnpm install
pnpm devBuild the package:
pnpm buildFeel free to open a PR if something's missing ๐
