Component packs › Pips › 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.
| Prop | Type | Default | Description |
|---|---|---|---|
dice | number | 2 | Number of dice, 1 to 3. Default 2. |
label | string | "Roll dice" | Button text. Default "Roll dice". |
disabled | boolean | ||
width | number | 340 | Tray width in px. Default 340. |
onRoll | (values: number[], total: number) => void | Called with every die's value and the total once they come to rest. | |
autoplay | number | false | Showcase mode: rolls every N ms while visible. | |
seed | number | Seed for the showcase's first throws. |
readonly values: number[]roll(): voiddestroy(): voidimport RollButton from './RollButton';
<RollButton />The Vue, HTML, Next.js, Tailwind and Motion versions take the same options.
Good for: Skeuomorphic UI.