Home / Projects / ng-spinner-wheel
Open source · MIT · Angular 18–22

ng-spinner-wheel for Angular.

A lightweight, customizable, standalone spinner wheel with weighted items. Built for raffles, lucky draws, prize wheels and gamified selections. Works in Ionic too.

Why use it

Features

Standalone component

No NgModule needed. Import it straight into your component's imports.

Weighted slices

Heavier items get bigger slices and a higher chance of winning.

Canvas rendering

Sharp on high-DPI screens, with no external image assets.

Angular 18 – 22

Compatible with current Angular releases and usable inside Ionic apps.

Customizable

Per-item colors, text color, font size, custom spin button image, and spin duration.

Programmatic control

Start, stop early, or regenerate the wheel from code, and listen for the winner.

Get started

Install

terminal
npm install ng-spinner-wheel

Package page: npmjs.com/package/ng-spinner-wheel ↗

Example

Usage

app.component.ts
import { Component, ViewChild } from '@angular/core';
import { MenuItems, NgSpinnerWheelComponent } from 'ng-spinner-wheel';

@Component({
  selector: 'app-root',
  imports: [NgSpinnerWheelComponent],
  templateUrl: './app.component.html'
})
export class AppComponent {
  allItems: MenuItems[] = [
    { menuTitle: 'Gold' },
    { menuTitle: 'Dark', menuWeight: 2, id: 'ABC' },
    { menuTitle: 'Silver', menuWeight: 2, backColor: '#C0C0C0', textColor: '#FFFFFF', fontSize: '12px' },
  ];

  @ViewChild('spinner') spinner!: NgSpinnerWheelComponent;

  onSpinCompleted(item: MenuItems) {
    console.log('Winner:', item);
  }
}
app.component.html
<lib-ng-spinner-wheel
  #spinner
  [allItems]="allItems"
  [width]="300"
  [btnWidth]="60"
  (spinCompleted)="onSpinCompleted($event)">
</lib-ng-spinner-wheel>
The wheel redraws when you assign a new allItems array or change width. It does not detect in-place changes like push(), so assign a new array or call regenerate(). The pointer sits at the top of the wheel; supply your own marker there.
Reference

API

Inputs

InputTypeDefaultDescription
allItemsMenuItems[][]Items on the wheel.
widthnumber260Wheel diameter in px.
btnWidthnumber30Spin button diameter in px.
btnImagestring–Image URL for the spin button. A built-in "SPIN" button is used if omitted.
shufflebooleantrueShuffle slice order when items change.
minSpinTimenumber5000Minimum ms before the wheel starts slowing down.
maxSpinTimenumber8500Maximum ms before the wheel starts slowing down.

MenuItems

FieldTypeDescription
menuTitlestringLabel. Use \n for multiple lines.
idstring?Your own identifier (Id is also accepted).
menuWeightnumber?Relative weight, default 1.
backColorstring?Slice color, random if omitted.
textColorstring?Label color, auto-contrast if omitted.
fontSizestring?For example '14px', default '15px'.
percentagenumber?Computed by the wheel.

Outputs & methods

NameDescription
(spinCompleted)Emits the winning MenuItems item when the wheel stops.
startSpin()Start spinning programmatically, same as clicking the button.
stops()Start slowing the wheel down early.
regenerate()Reinitialize the wheel from the current inputs.