TipSplitter
Split a bill: type the total, pick a tip, set the headcount. Each share rolls to its new figure, rounded up so the table is never short. Finance.
Open playgroundPeople
3
Each person pays
$33.12
Tip$12.96of$99.36
About
TipSplitter is a React component in the Finance category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { TipSplitter } from "@ashutoshswamy/smoui" and set defaultBill, defaultTip, defaultPeople among its 5 props.
Install
npm i @ashutoshswamy/smouiUsage
import { TipSplitter } from "@ashutoshswamy/smoui";
<TipSplitter defaultBill={86.4} defaultTip={15} defaultPeople={3} />Props 5
- defaultBill
Starting total.
number- defaultTip
Starting tip in percent.
number- defaultPeople
Starting headcount.
number- tips
Tip choices. Default 10, 15, 20, 25.
number[]- currency
ISO code. Default USD.
string
More finance components
- AmountInputA big amount field. Digits group as you type, the figure shakes and turns red past your balance, and chips add to it or fill the max.
- BalanceChartBalance over time. Switch the range and the line morphs; drag across it and the figure follows with the change since the start.
- CandlestickChartCandles that grow from their middle when scrolled into view. Point at one: the rest dim and a readout gives open, high, low and close.
- CardFormA payment card that fills in as you type. Digits group themselves, the brand is read from the first numbers, the number is checked with Luhn, and the card turns over when you reach the CVC.
- CreditCardA card that tilts toward the pointer and flips to its back. The number is masked down to the last four digits.
- CurrencySwapA two-way converter. Type an amount and the result eases to its value; the swap button turns the pair around.