Plinko

Preview

Score 0 · 0 balls

Install

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

$ bunx --bun shadcn add @beui/plinko

API Reference

rows?
number

Rows of pegs when `slots` isn't passed. Default 12.

Default12
slots?
PlinkoValue[]

Slot values, left to right. Their count sets the board: n slots get n - 1 rows of pegs, so `rows` is ignored when this is passed. Without it the slots come from `plinkoSlots(rows)`. Fewer than 2 slots render nothing.

Default—
onLand?
((slot: number, value: PlinkoValue) => void)

Called with the slot index and its value when a ball lands.

Default—
maxBalls?
number

Balls allowed in flight at once. Default 12.

Default12
dropLabel?
string

Label of the drop button. Default "Drop ball".

DefaultDrop ball
pegFlash?
boolean

Flash each peg as the ball hits it (controlled). Its button is hidden with reduced motion, where no pegs are hit.

Default—
defaultPegFlash?
boolean

Initial peg flash state when uncontrolled. Default true.

Defaulttrue
onPegFlashChange?
((pegFlash: boolean) => void)

Called when the peg flash button is toggled.

Default—
pegFlashLabel?
string

Tooltip and accessible name of the peg flash button. Default "Peg flash".

DefaultPeg flash
sound?
boolean

Click on every peg hit and landing (controlled).

Default—
defaultSound?
boolean

Initial sound state when uncontrolled. Default false.

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

Called when the sound button is toggled.

Default—
soundLabel?
string

Tooltip and accessible name of the sound button. Default "Sound".

DefaultSound
aria-label?
string

Accessible name for the board. Default "Plinko board".

DefaultPlinko board
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