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.
Example
Usage
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); } }
<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
| Input | Type | Default | Description |
|---|---|---|---|
allItems | MenuItems[] | [] | Items on the wheel. |
width | number | 260 | Wheel diameter in px. |
btnWidth | number | 30 | Spin button diameter in px. |
btnImage | string | – | Image URL for the spin button. A built-in "SPIN" button is used if omitted. |
shuffle | boolean | true | Shuffle slice order when items change. |
minSpinTime | number | 5000 | Minimum ms before the wheel starts slowing down. |
maxSpinTime | number | 8500 | Maximum ms before the wheel starts slowing down. |
MenuItems
| Field | Type | Description |
|---|---|---|
menuTitle | string | Label. Use \n for multiple lines. |
id | string? | Your own identifier (Id is also accepted). |
menuWeight | number? | Relative weight, default 1. |
backColor | string? | Slice color, random if omitted. |
textColor | string? | Label color, auto-contrast if omitted. |
fontSize | string? | For example '14px', default '15px'. |
percentage | number? | Computed by the wheel. |
Outputs & methods
| Name | Description |
|---|---|
(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. |
Try it
See it spin.
Open the live demo, grab the package from npm, or read the source and contribute on GitHub.