Preview

Session profit +$0.00

Win chance
49.50%
Profit on win
$1.00
  • Recent rounds show here

49.50% chance of 2× · marked cards win

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/slide-game

API Reference

target?
number

Target multiplier (controlled). A result at or above it wins. Applies from the next round. Values below 1.01× play as 1.01×.

Default—
defaultTarget?
number

Initial target when uncontrolled. Default 2.

Default2
onTargetChange?
((target: number) => void)

Called when the Target menu changes between rounds.

Default—
targets?
number[]

Targets offered in the menu. Default 1.5×, 2×, 3×, 5×, 10×, 25×, 100×. Values below 1.01× are left out.

Default[1.5, 2, 3, 5, 10, 25, 100]
bet?
number

Bet amount (controlled), used for the profit readout and passed to `onResult`.

Default—
defaultBet?
number

Initial bet when uncontrolled. Default 1.

Default1
onBetChange?
((bet: number) => void)

Called when the bet changes.

Default—
currency?
string

Currency symbol shown before the bet and the profit. Default "$".

Default$
formatAmount?
((amount: number) => string)

Formats the profit. Default the currency symbol and two decimals ($1.50).

Default—
getResult?
(() => number | Promise<number>)

Decides each round's result, called once when the round starts. Return a number, or a Promise for one (a server round, a provably fair hash): the button shows Starting… until it settles, and a rejection cancels the round. Values below 1 or not finite play as 1. Default `slideResult()`. The win chance shown assumes its 1% edge.

Default—
onResult?
((result: number, target: number, bet: number) => void)

Called when the reel stops, with the result, the round's target and its bet. The round wins when result >= target. Not called for a round still sliding when the game unmounts; settle those from your own record of `getResult`.

Default—
duration?
number

Slide length in seconds. Default 4.

Default4
sound?
boolean

Play synthesized sounds (controlled): a tick per card into the center and a chime on a win.

Default—
defaultSound?
boolean

Initial sound state when uncontrolled. Default false.

Defaultfalse
onSoundChange?
((sound: boolean) => void)

Called when the sound button is toggled.

Default—
aria-label?
string

Accessible name for the game. Default "Slide".

DefaultSlide
className?
string
Default—

Keep in mind

Some components on this site are inspired by or recreated from existing work across the web. I'm not here to take credit; just to learn, experiment, and sometimes push things a bit further. If something looks familiar and I forgot to mention you, reach out and I'll fix that right away.

Updated