Skip to content

Some vue3 package to display and customize a wheel of fortune

Notifications You must be signed in to change notification settings

aurhell/vue-roue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

33 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽก Roue

npm version License: MIT Vue 3

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


Demo

Vue Roue Demo

๐Ÿš€ Features

  • ๐ŸŽฏ 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
    • ...

๐Ÿ“ฆ Installation

pnpm add vue-roue
# or
npm install vue-roue

๐Ÿ›  Usage

<!-- 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>

โš™๏ธ Props

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.

๐Ÿ” Exposed Methods

Call spin() programmatically using ref:

const wheelRef = ref()
wheelRef.value?.spin()

๐Ÿ“ค Events

Event Payload Description
winner string Emitted when a segment wins.

๐Ÿงฉ Types

type HexColor = `#${string}`

type Segment = {
  name: string
  color?: HexColor
}

๐ŸŽจ Presets

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

๐Ÿ‘ฅ Contribution

Clone the repo and run locally:

pnpm install
pnpm dev

Build the package:

pnpm build

Feel free to open a PR if something's missing ๐Ÿ™

About

Some vue3 package to display and customize a wheel of fortune

Resources

Stars

Watchers

Forks

Packages

No packages published