Skip to content

Dice Roll

Pro

3D dice that you throw into a felt tray with real physics: they spin, bounce, roll over their edges, and rock to rest on fair faces. d6 and d20.

  • Base UI
  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 11, 2026 · Pro license

Playground

Loading the preview

Props

Needs your Pro API key in GELATIN_UI_PRO_TOKEN. Set it up

Pro itemAPI key required

Dice Roll needs a Pro API key

Try the live preview for free. With Pro, the add command above puts the source in your project.

Files it adds
24
More Pro items, one API key
+327
Your coding agent runs it
1 cmd

$79$129once, for life

Already have Pro? Sign in to set up your API key.

Put the dice in the tray, then add the total and a trigger.

backgammon-turn.tsx

DiceRoll

<div>
PropTypeDefaultDescription
onRollEnd—Called when the dice come to rest, with their faces in the order the dice render.
onRollStart—Called when a throw starts: a press on the tray or the trigger that the dice take.
disabledbooleanfalseStops new throws. A throw in the air still lands.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

DiceRollTray

<button>
PropTypeDefaultDescription
classNamestring—
styleCSSProperties—
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
nativeButtonbooleantrueWhether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

DiceRollDie

<span>
PropTypeDefaultDescription
variant"ivory""onyx""ruby"—
sides6206A cube (6) or an icosahedron (20).
...props<span> attributes—Every other attribute goes to the <span>, with a ref.

DiceRollTrigger

<button>
PropTypeDefaultDescription
glass"clear""dark""light"—
rounded"default""full"—
size"default""icon""icon-lg""icon-sm""icon-xs""lg""sm""xl""xs"—
variant"dashed""default""destructive""destructive-outline""ghost""link""media""outline""secondary"—
classNamestring—
busyboolean—The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading.
spinnerPlacement"center""start"—center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label.
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

DiceRollTotal

<span>
PropTypeDefaultDescription
...props<span> attributes—Every other attribute goes to the <span>, with a ref.
  • Put one DiceRollDie in DiceRollTray for each die. Set sides to 6 or 20, and variant to ivory, onyx, or ruby.
  • Read the faces in onRollEnd. It runs when every die is at rest, with the faces in the order the dice render.
  • Use onRollStart to hide an old result or lock a choice while the dice roll. It runs once per throw.
  • Show the sum with DiceRollTotal. Children go before the number (Total ).
  • Use your own text for game rules: modifiers, doubles, a natural 20.
  • For a fair pick between two results, use Coin Flip.
  • For a number that people type or step, use Number Field.
EnterorSpaceThrows the dice when the tray or DiceRollTrigger has focus. A press while the dice roll does nothing.

The tray is a button with the name "Roll the dice". Give it your own aria-label when the roll has a job.

Show the result as text (DiceRollTotal or your own line), not only as the faces of the dice.

The dice spin fast for about a second, then roll slower to rest. They do not flash.

Throw
progress · about 1.5 s on one linear clock: an arc with spin, a bounce, rolls over the edges, and a rock to rest
Total
statusPop · the total pops in when the dice come to rest, and fades out on fadeExit when the next throw starts

Built with

Installs with Dice Roll

Components
Button
  1. AddedDice Roll, with Button.
Open the release