Component packs › Pips › Roll Button

Roll Button

Dice are thrown onto a felt tray, bounce, knock into each other and roll to a stop; the faces on top are the result.

Roll Button is a randomiser from Pips, a component pack with 6 dice controls: Controls built from dice that tumble, bounce and land the way dice do. Price: $2 for the whole pack.

Built with: throw physics, rolling without slipping, die to die hits.

Code: React and Next.js (TypeScript), Vue 3, plain HTML/CSS/JS, Tailwind CSS v4 and Motion (motion.dev). No npm packages needed. Keyboard accessible, with a reduced-motion version, in dark and light.

Roll Button props

PropTypeDefaultDescription
dicenumber2Number of dice, 1 to 3. Default 2.
labelstring"Roll dice"Button text. Default "Roll dice".
disabledboolean
widthnumber340Tray width in px. Default 340.
onRoll(values: number[], total: number) => voidCalled with every die's value and the total once they come to rest.
autoplaynumber | falseShowcase mode: rolls every N ms while visible.
seednumberSeed for the showcase's first throws.

Methods on the ref

Use it in React

import RollButton from './RollButton';

<RollButton />

The Vue, HTML, Next.js, Tailwind and Motion versions take the same options.

More in Pips

Good for: Skeuomorphic UI.