remold/ui

Split amount

Splitting a bill: tap someone at the table and their face flies into the split, the bar re-divides and every share rolls to the new amount, cents and all. Pick a tip, then request what you're owed. Built on Base UI's Button and Toggle Group.

Base UIMotion

Dinner at BukaFri 14 Nov · 5 at the tableincl. 15% tip
Tip
  • You
  • Ama Owusu
Also at the table

2 people, $63.25 each.

Things to try

  • Add someone. Tap a face under "Also at the table": it flies up into the split, the bar re-divides and every share rolls down.
  • Leave someone out. Press × on their row and they go back to the table; the others' shares grow.
  • Change the tip. The total and every share roll to the new amount.
  • Request the money. The button asks the others for what they owe, then says it's sent.
  • Look at the cents. The shares always add up to the bill exactly.

Install

npx shadcn@latest add https://your-docs-site/r/split-amount.json

Dependencies

The install command adds these for you. If you copy the code by hand, install them yourself.

npm install @base-ui/react @hugeicons/core-free-icons @hugeicons/react @remold-ui/react motion

How it works

  • One face, two places. Each person's face is the same Motion element in the tray and in the list, so it travels between them when they join or leave the split.
  • The bill re-divides. Each slice of the bar is a Motion flex item, so they resize together; the amounts roll with the Odometer.
  • Built on Base UI. Button for adding, removing and requesting; ToggleGroup for the tip. SplitAmount takes value / onValueChange (who's paying and the tip) or runs on its own, plus your diners and an onRequest hook.
  • No lost cents. What's left after an even split goes a cent at a time to the first people.

On this page