Split evenly: the total is a ball that splits into one ball per row and rolls each figure; locked rows keep theirs and a meter counts down to zero.
Click meTap me
Q3 channels
Budget €12,500.03
Channel
Last quarter
Allocation
Lock
Search adsGrowth
€4,800.00
€5,200.00€5,200.00€0.00€0.00 vs last quarter
SocialBrand
€3,500.00
€3,100.00€3,100.00€0.00€0.00 vs last quarter
EventsField
€3,000.00
€2,700.00€2,700.00€0.00€0.00 vs last quarter
PodcastsNew channel
€0.00
€0.00€0.00€0.00€0.00 vs last quarter
Left to allocateOver the total byBalanced€12,500.03€12,500.03
even-split · , lively
even-split-demo.tsx
When to use
Use it when what remains of a total must be shared evenly across rows, with some rows committed. Amounts are in minor units, so the shares add up exactly.
When not to use
For free-form allocation of a whole across parts use Allocation Slider. For a single editable number use Number Input.
Use Even Split when what is left of a total must be shared evenly across rows: a budget allocation, a dinner bill, a ticket round-robin. The total is a ball on the button. One press splits it into one ball per row; each flies to its amount, squashes on it and rolls the figure to the share. Lock the rows that are already committed: they keep their figure and the others share the rest. The balance meter shows what is still unallocated and reaches zero as the last ball lands; the rounding cents go to the last unlocked row, whose ball is visibly bigger, and the meter says so. The button then reads Undo split. For free-form allocation use Allocation Slider; for a single value, a number input.
It is a compound: EvenSplit is the stage that hosts the flights and must contain the trigger and the amounts, because the balls fly between them. total is in minor units (cents) so the shares add up exactly. Each EvenSplitAmount takes its index and its value (minor units, before the split). At most 8 balls fly; further rows change figure without one.
EvenSplitLock is a toggle (aria-pressed) that keeps its row out of the split. Locks are uncontrolled with defaultLocked, or controlled with locked and onLockedChange (row indices). Changing a lock while split re-shares the other rows at once. splitShares(total, values, locked) returns the same figures for your own state.
EvenSplitBalance is the difference to the total: what is left to allocate (or over), a bar of the allocated part and a note on where the rounding went. labels renames its three states and remainderNote writes the note (null hides it).
EvenSplitDelta shows a row's change against a baseline (last quarter, the budget), rolling with the figure.
split, defaultSplit and onSplitChange control the state; changing it from outside rolls the figures without flights. onSplit receives the figures in row order. format, locale and currency control the figures (default Intl.NumberFormat), announce overrides the live region text (it now also receives the locked rows) and piece replaces the ball's shape. EvenSplitTrigger takes children (the label before the split) and undoLabel.
Presets: fan (default, nearest row first, balls fan out sideways), deal (rows in order, 60 ms apart, like dealing cards) and drop (no fan, straight drops, for a narrow column under the button).
Set the character for the whole app with MotionKitProvider, or per instance with temperament (calm, lively, playful). It changes motion intensity only, never the drawing.
The default demo: a Q3 marketing budget. Search ads is committed and locked, the draft leaves part of the budget unallocated, and Split the rest shares it across the other channels. Each row shows its change against last quarter.
Click meTap me
Q3 channels
Budget €12,500.03
Channel
Last quarter
Allocation
Lock
Search adsGrowth
€4,800.00
€5,200.00€5,200.00€0.00€0.00 vs last quarter
SocialBrand
€3,500.00
€3,100.00€3,100.00€0.00€0.00 vs last quarter
EventsField
€3,000.00
€2,700.00€2,700.00€0.00€0.00 vs last quarter
PodcastsNew channel
€0.00
€0.00€0.00€0.00€0.00 vs last quarter
Left to allocateOver the total byBalanced€12,500.03€12,500.03
Three guests share a receipt with the deal preset. Tomás pays his own order, so his lock is on (controlled by name). Remove a guest and the meter shows what is not covered; split again to settle it.
Click meTap me
Team dinner
Receipt total €188.50
Mara
Pasta, water
€52.00€52.00
Tomás
Pays own order
€74.50€74.50
Ines
Salad, coffee
€62.00€62.00
Not coveredCharged over the receipt bySettled€188.50€188.50
The trigger is a native button; its name changes to the undo label once split, and aria-describedby can point at the total. It is disabled while fewer than two rows are registered or every row is locked.
Each EvenSplitLock is a native toggle button with aria-pressed; give it an aria-label naming its row.
EvenSplitBalance is a role="meter" with the allocated amount as its value and the state as aria-valuetext ("Left to allocate €1,500.03").
A polite live region announces the result, for example "Split into 3 parts of €2,433.34. The last gets €2,433.35. 1 locked kept their amount." Pass announce to localize it.
The balls, humps, seat and bar are aria-hidden; the figures stay real text.
Focus shows a 3 px ring; label contrast stays at least 4.5:1 in both themes.
No humps, flights or squash: the ball fades out and the seat fades in, the figures crossfade to the shares, and the balance bar and tick jump to their end state.
One requestAnimationFrame loop runs only while something moves; the digit roll uses the Web Animations API and the bar a CSS transform transition.
Balls are positioned from measured cell positions at the moment of the split; at most 8 balls fly.
The balls are drawn as one union with a single rim, using transforms only.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom.
Dependencies
motion
Triggers
click, press, a value change
Reduced motion
No humps, flights or squash: the ball fades out and its dashed seat fades in, each figure crossfades to its share and the balance bar and tick jump to their end state.
Keyboard
Enter / Space
On the trigger: plays the charge (the ball spreads into humps), then splits what the locked rows leave; on the split button, undoes it
Enter / Space
On a row lock: keeps the row's figure out of the split (the others re-share at once)
Tab
Moves focus between the trigger and the row locks; focus stays put while the shares fly
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)