Split bills app
Shared costs for a group trip: balances as bars either side of zero, a list of who paid for what, and a slide-to-settle control that can't be triggered by a pocket tap.
"use client";
import {
useEffect,
useRef,
useState,
type CSSProperties,
type PointerEvent,
} from "react";
import "./split-bills.css";
export type Member = { name: string; color: string; balance: number };
export type Expense = {
title: string;
by: string;
amount: number;
kind: string;
date: string;
};
export type Debt = { to: string; amount: number };
type SplitBillsProps = {
group: string;
/** The first member is you. A positive balance means the group owes them. */
members: Member[];
expenses: Expense[];
/** What you still owe, in the order you'll settle it. */
debts: Debt[];
currency?: string;
};
const initials = (n: string) => n.slice(0, 1).toUpperCase();
const TABS = ["balances", "expenses"] as const;
const COINS = 16;
/** A number that glides to its new value instead of jumping (ease-out, about 0.8s). */
function useTween(value: number, ms = 800) {
const [shown, setShown] = useState(value);
const from = useRef(value);
useEffect(() => {
const calm = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const a = from.current;
const t0 = performance.now();
let raf = 0;
const step = (t: number) => {
const k = calm || ms <= 0 ? 1 : Math.min(1, (t - t0) / ms);
const v = a + (value - a) * (1 - Math.pow(1 - k, 3));
from.current = v;
setShown(v);
if (k < 1) raf = requestAnimationFrame(step);
};
raf = requestAnimationFrame(step);
return () => cancelAnimationFrame(raf);
}, [value, ms]);
return shown;
}
function Money({
value,
currency,
sign = false,
}: {
value: number;
currency: string;
sign?: boolean;
}) {
const v = useTween(value);
const neg = sign && v < -0.004;
return (
<span className="gu-split__num">
{neg ? "−" : ""}
{currency}
{Math.abs(v).toFixed(2)}
</span>
);
}
function BalanceRow({
m,
widest,
currency,
flash,
index,
}: {
m: Member;
widest: number;
currency: string;
flash: boolean;
index: number;
}) {
const side =
m.balance > 0.004 ? "gets" : m.balance < -0.004 ? "owes" : "even";
return (
<li
data-side={side}
data-flash={flash}
style={{ "--i": index } as CSSProperties}
>
<span className="gu-split__who">
<span
className="gu-split__face"
style={{ background: m.color }}
aria-hidden="true"
>
{initials(m.name)}
</span>
{m.name}
</span>
<span className="gu-split__bar" aria-hidden="true">
<span
style={{ "--k": Math.abs(m.balance) / widest } as CSSProperties}
/>
</span>
<span className="gu-split__amount">
{side === "even" ? (
"Square"
) : (
<>
{side === "gets" ? "gets " : "owes "}
<Money value={Math.abs(m.balance)} currency={currency} />
</>
)}
</span>
</li>
);
}
/**
* SplitBills: a shared-costs screen for a group trip.
* - Balances as bars either side of zero: right gets money back, left owes. Bars grow in one after another.
* - Every amount glides to its new value; tabs slide in from the side you came from.
* - Settle up with a slide: a green fill follows your thumb, and finishing bursts coins out of the track.
*/
export function SplitBills({
group,
members: start,
expenses,
debts: startDebts,
currency = "€",
}: SplitBillsProps) {
const [members, setMembers] = useState(start);
const [debts, setDebts] = useState(startDebts);
const [tab, setTab] = useState<(typeof TABS)[number]>("balances");
const [dir, setDir] = useState(0);
const [settled, setSettled] = useState(false);
const [flash, setFlash] = useState<string[]>([]);
const [burst, setBurst] = useState(0);
const track = useRef<HTMLDivElement>(null);
const thumb = useRef<HTMLButtonElement>(null);
const drag = useRef<{ start: number; x: number } | null>(null);
const total = expenses.reduce((s, e) => s + e.amount, 0);
const widest = Math.max(...start.map((m) => Math.abs(m.balance)), 1);
const debt = debts[0];
const share = total / members.length;
const money = (n: number) => `${currency}${Math.abs(n).toFixed(2)}`;
const place = (x: number) => {
track.current?.style.setProperty("--x", `${x}px`);
track.current?.style.setProperty("--fill", `${x / Math.max(1, maxX())}`);
};
// After the "Settled" moment, move on to the next debt.
useEffect(() => {
if (!settled) return;
const id = window.setTimeout(() => {
setDebts((d) => d.slice(1));
setSettled(false);
setFlash([]);
track.current?.style.setProperty("--x", "0px");
track.current?.style.setProperty("--fill", "0");
}, 2400);
return () => window.clearTimeout(id);
}, [settled]);
const maxX = () =>
track.current && thumb.current
? track.current.clientWidth - thumb.current.offsetWidth - 8
: 0;
const settle = () => {
if (!debt || settled) return;
place(maxX());
setSettled(true);
setBurst((b) => b + 1);
setFlash([members[0].name, debt.to]);
setMembers((ms) =>
ms.map((m, i) =>
i === 0
? { ...m, balance: Math.round((m.balance + debt.amount) * 100) / 100 }
: m.name === debt.to
? {
...m,
balance: Math.round((m.balance - debt.amount) * 100) / 100,
}
: m,
),
);
};
const down = (e: PointerEvent<HTMLButtonElement>) => {
if (settled) return;
e.currentTarget.setPointerCapture(e.pointerId);
drag.current = { start: e.clientX, x: 0 };
track.current!.dataset.dragging = "true";
};
const move = (e: PointerEvent<HTMLButtonElement>) => {
if (!drag.current) return;
const raw = e.clientX - drag.current.start;
const max = maxX();
// A little resistance past the end, like pulling against a spring.
const x =
raw > max ? max + Math.min(10, (raw - max) * 0.12) : Math.max(0, raw);
drag.current.x = x;
place(x);
};
const up = () => {
if (!drag.current) return;
const done = drag.current.x > maxX() * 0.88;
drag.current = null;
track.current!.dataset.dragging = "false";
if (done) settle();
else place(0);
};
const pick = (t: (typeof TABS)[number]) => {
setDir(TABS.indexOf(t) - TABS.indexOf(tab));
setTab(t);
};
const you = members[0];
const to = debt && members.find((m) => m.name === debt.to);
return (
<div className="gu-split">
<header className="gu-split__top">
<p className="gu-split__eyebrow">Shared costs</p>
<h2 className="gu-split__title">{group}</h2>
<div className="gu-split__meta">
<span className="gu-split__faces" aria-hidden="true">
{members.map((m, i) => (
<span
key={m.name}
style={{ background: m.color, "--i": i } as CSSProperties}
>
{initials(m.name)}
</span>
))}
</span>
<span>
<Money value={total} currency={currency} /> spent ·{" "}
<Money value={share} currency={currency} /> each
</span>
</div>
</header>
<div className="gu-split__tabs" role="tablist" aria-label="View">
{TABS.map((t) => (
<button
key={t}
type="button"
role="tab"
aria-selected={tab === t}
onClick={() => pick(t)}
>
{t === "balances" ? "Balances" : "Expenses"}
</button>
))}
<span
className="gu-split__pill"
data-right={tab === "expenses"}
aria-hidden="true"
/>
</div>
<div className="gu-split__panel">
<div
key={tab}
className="gu-split__sheet"
data-dir={dir > 0 ? "left" : dir < 0 ? "right" : "none"}
>
{tab === "balances" ? (
<ul className="gu-split__balances" aria-label="Balances">
{members.map((m, i) => (
<BalanceRow
key={m.name}
m={m}
widest={widest}
currency={currency}
flash={flash.includes(m.name)}
index={i}
/>
))}
</ul>
) : (
<ul className="gu-split__expenses" aria-label="Expenses">
{expenses.map((e, i) => (
<li key={e.title} style={{ "--i": i } as CSSProperties}>
<span className="gu-split__kind" aria-hidden="true">
{e.kind}
</span>
<span className="gu-split__what">
<strong>{e.title}</strong>
<span>
{e.by === you.name ? "You" : e.by} paid · {e.date}
</span>
</span>
<span className="gu-split__cost">
<strong>{money(e.amount)}</strong>
<span>your share {money(e.amount / members.length)}</span>
</span>
</li>
))}
</ul>
)}
</div>
</div>
{/* Settle up */}
<section
className="gu-split__settle"
data-settled={settled}
data-empty={!debt}
aria-live="polite"
>
{debt && to ? (
<>
<p className="gu-split__owe">
<span className="gu-split__owe-text" key={String(settled)}>
{settled ? (
<>Settled with {to.name}</>
) : (
<>
You owe <strong>{to.name}</strong>
</>
)}
</span>
<span className="gu-split__owe-amount">
<Money value={settled ? 0 : debt.amount} currency={currency} />
</span>
</p>
<div ref={track} className="gu-split__track">
<span className="gu-split__fill" aria-hidden="true" />
<span className="gu-split__label" aria-hidden="true">
{settled ? "Settled" : "Slide to settle up"}
</span>
<span className="gu-split__chevrons" aria-hidden="true">
<i />
<i />
<i />
</span>
<button
ref={thumb}
type="button"
className="gu-split__thumb"
aria-label={`Settle up ${money(debt.amount)} with ${to.name}`}
onPointerDown={down}
onPointerMove={move}
onPointerUp={up}
onPointerCancel={up}
// A keyboard press (Enter or Space) gives a click with detail 0; mouse and touch must slide.
onClick={(e) => e.detail === 0 && settle()}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
{settled ? (
<path
className="gu-split__check"
pathLength={1}
d="m5 12.5 4.5 4.5L19 7.5"
/>
) : (
<path
className="gu-split__arrow"
d="M5 12h13M13 6l6 6-6 6"
/>
)}
</svg>
</button>
</div>
{burst > 0 && settled && (
<span className="gu-split__coins" key={burst} aria-hidden="true">
{Array.from({ length: COINS }, (_, i) => {
const a =
-Math.PI / 2 +
((i / (COINS - 1)) * 1.6 - 0.8) * Math.PI * 0.75;
const d = 70 + ((i * 37) % 60);
return (
<i
key={i}
style={
{
"--dx": `${Math.cos(a) * d}px`,
"--dy": `${Math.sin(a) * d}px`,
"--rot": `${((i * 53) % 360) - 180}deg`,
"--delay": `${(i % 5) * 30}ms`,
} as CSSProperties
}
/>
);
})}
</span>
)}
</>
) : (
<p className="gu-split__square">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="10" pathLength={1} />
<path d="m7.5 12.5 3 3 6-6.5" pathLength={1} />
</svg>
You’re all square. Nice.
</p>
)}
</section>
</div>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Split bills app
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A shared-costs screen for phones, for a group trip. It shows who is owed and who owes as bars either side of a zero line, lists every expense with who paid and your share, and lets you settle up with a slide control, so a stray tap in a pocket can never mark a debt as paid.
## Layout and look
- Fills its parent; paper #f3f3ef, white cards, ink #141414, muted #6d6d68, green #0d8f6f for money coming back, orange #ff5a1f for money owed. System font.
- Safe areas: top padding = safe-area-inset-top + 10px, bottom = safe-area-inset-bottom + 12px.
- Header: "Shared costs" (14px muted), the group name (30px, weight 750), then overlapping 28px initial avatars and "€684.20 spent · €171.05 each".
- Tabs: Balances / Expenses in a pill track; the selected one is a white pill with a soft shadow.
- Balances card: one row per person with a face, the name and "gets €141.35" (green) or "owes €42.50" (orange) or "Square" (muted); under it an 8px bar with a centre line, filling right in green or left in orange, scaled to the largest balance.
- Expenses card: a 42px rounded square with an emoji, the title, "Jonas paid · Fri", and on the right the amount and "your share €78.10".
- Settle card at the bottom: ink, radius 28px. "You owe Jonas" with the amount at 26px, then a 64px track with a white 56px round thumb holding an arrow. The words "Slide to settle up" have a light sweeping across them.
## Behavior and motion
1. Drag the thumb right; it follows the finger and a green light fills the track behind it while the label fades.
2. Released before 88% of the way, it springs back (0.45s, cubic-bezier(0.16, 1, 0.3, 1)). Past it, the card turns green, the arrow becomes a check and the label reads "Settled".
3. The balances update at once: your bar shrinks to zero, the other person's shrinks by the same amount.
4. After about two seconds the card moves on to the next debt, or says "You're all square. Nice."
Extra motion that makes it feel finished:
- Avatars pop in one by one with a slight overshoot (cubic-bezier(0.34, 1.4, 0.5, 1)). Balance rows rise in 60ms apart and each bar grows from the zero line.
- Every money amount glides to its new value over 0.8s (ease-out cubic, requestAnimationFrame) instead of jumping.
- Tabs: a white pill springs under the selected tab; the new list slides in 40px from the side you moved towards.
- The slide track: a green fill trails the thumb, three chevrons shimmer towards the end, the arrow on the thumb nudges right now and then, the thumb grows slightly while held and pulls a little past the end like a spring.
- Settling: the card thumps (scale 1.025), the arrow becomes a check that draws itself, 16 gold coins burst out of the end of the track and fall away, and the two people involved light up briefly in the list.
- All square: a circle and a check draw themselves before the text.
## Accessibility
- The thumb is a real button labelled "Settle up €42.50 with Jonas". Keyboard users press Enter or Space (the click comes with detail 0); mouse and touch must slide.
- The settle card is aria-live so the result is announced. Tabs use role="tablist" and aria-selected.
- prefers-reduced-motion: no shine on the label, no easing on bars or the thumb.
## Props
group, members: { name, color, balance }[] (the first one is you), expenses: { title, by, amount, kind, date }[], debts: { to, amount }[], currency?: string ("€")
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### SplitBills.tsx
```tsx
"use client";
import {
useEffect,
useRef,
useState,
type CSSProperties,
type PointerEvent,
} from "react";
import "./split-bills.css";
export type Member = { name: string; color: string; balance: number };
export type Expense = {
title: string;
by: string;
amount: number;
kind: string;
date: string;
};
export type Debt = { to: string; amount: number };
type SplitBillsProps = {
group: string;
/** The first member is you. A positive balance means the group owes them. */
members: Member[];
expenses: Expense[];
/** What you still owe, in the order you'll settle it. */
debts: Debt[];
currency?: string;
};
const initials = (n: string) => n.slice(0, 1).toUpperCase();
const TABS = ["balances", "expenses"] as const;
const COINS = 16;
/** A number that glides to its new value instead of jumping (ease-out, about 0.8s). */
function useTween(value: number, ms = 800) {
const [shown, setShown] = useState(value);
const from = useRef(value);
useEffect(() => {
const calm = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const a = from.current;
const t0 = performance.now();
let raf = 0;
const step = (t: number) => {
const k = calm || ms <= 0 ? 1 : Math.min(1, (t - t0) / ms);
const v = a + (value - a) * (1 - Math.pow(1 - k, 3));
from.current = v;
setShown(v);
if (k < 1) raf = requestAnimationFrame(step);
};
raf = requestAnimationFrame(step);
return () => cancelAnimationFrame(raf);
}, [value, ms]);
return shown;
}
function Money({
value,
currency,
sign = false,
}: {
value: number;
currency: string;
sign?: boolean;
}) {
const v = useTween(value);
const neg = sign && v < -0.004;
return (
<span className="gu-split__num">
{neg ? "−" : ""}
{currency}
{Math.abs(v).toFixed(2)}
</span>
);
}
function BalanceRow({
m,
widest,
currency,
flash,
index,
}: {
m: Member;
widest: number;
currency: string;
flash: boolean;
index: number;
}) {
const side =
m.balance > 0.004 ? "gets" : m.balance < -0.004 ? "owes" : "even";
return (
<li
data-side={side}
data-flash={flash}
style={{ "--i": index } as CSSProperties}
>
<span className="gu-split__who">
<span
className="gu-split__face"
style={{ background: m.color }}
aria-hidden="true"
>
{initials(m.name)}
</span>
{m.name}
</span>
<span className="gu-split__bar" aria-hidden="true">
<span
style={{ "--k": Math.abs(m.balance) / widest } as CSSProperties}
/>
</span>
<span className="gu-split__amount">
{side === "even" ? (
"Square"
) : (
<>
{side === "gets" ? "gets " : "owes "}
<Money value={Math.abs(m.balance)} currency={currency} />
</>
)}
</span>
</li>
);
}
/**
* SplitBills: a shared-costs screen for a group trip.
* - Balances as bars either side of zero: right gets money back, left owes. Bars grow in one after another.
* - Every amount glides to its new value; tabs slide in from the side you came from.
* - Settle up with a slide: a green fill follows your thumb, and finishing bursts coins out of the track.
*/
export function SplitBills({
group,
members: start,
expenses,
debts: startDebts,
currency = "€",
}: SplitBillsProps) {
const [members, setMembers] = useState(start);
const [debts, setDebts] = useState(startDebts);
const [tab, setTab] = useState<(typeof TABS)[number]>("balances");
const [dir, setDir] = useState(0);
const [settled, setSettled] = useState(false);
const [flash, setFlash] = useState<string[]>([]);
const [burst, setBurst] = useState(0);
const track = useRef<HTMLDivElement>(null);
const thumb = useRef<HTMLButtonElement>(null);
const drag = useRef<{ start: number; x: number } | null>(null);
const total = expenses.reduce((s, e) => s + e.amount, 0);
const widest = Math.max(...start.map((m) => Math.abs(m.balance)), 1);
const debt = debts[0];
const share = total / members.length;
const money = (n: number) => `${currency}${Math.abs(n).toFixed(2)}`;
const place = (x: number) => {
track.current?.style.setProperty("--x", `${x}px`);
track.current?.style.setProperty("--fill", `${x / Math.max(1, maxX())}`);
};
// After the "Settled" moment, move on to the next debt.
useEffect(() => {
if (!settled) return;
const id = window.setTimeout(() => {
setDebts((d) => d.slice(1));
setSettled(false);
setFlash([]);
track.current?.style.setProperty("--x", "0px");
track.current?.style.setProperty("--fill", "0");
}, 2400);
return () => window.clearTimeout(id);
}, [settled]);
const maxX = () =>
track.current && thumb.current
? track.current.clientWidth - thumb.current.offsetWidth - 8
: 0;
const settle = () => {
if (!debt || settled) return;
place(maxX());
setSettled(true);
setBurst((b) => b + 1);
setFlash([members[0].name, debt.to]);
setMembers((ms) =>
ms.map((m, i) =>
i === 0
? { ...m, balance: Math.round((m.balance + debt.amount) * 100) / 100 }
: m.name === debt.to
? {
...m,
balance: Math.round((m.balance - debt.amount) * 100) / 100,
}
: m,
),
);
};
const down = (e: PointerEvent<HTMLButtonElement>) => {
if (settled) return;
e.currentTarget.setPointerCapture(e.pointerId);
drag.current = { start: e.clientX, x: 0 };
track.current!.dataset.dragging = "true";
};
const move = (e: PointerEvent<HTMLButtonElement>) => {
if (!drag.current) return;
const raw = e.clientX - drag.current.start;
const max = maxX();
// A little resistance past the end, like pulling against a spring.
const x =
raw > max ? max + Math.min(10, (raw - max) * 0.12) : Math.max(0, raw);
drag.current.x = x;
place(x);
};
const up = () => {
if (!drag.current) return;
const done = drag.current.x > maxX() * 0.88;
drag.current = null;
track.current!.dataset.dragging = "false";
if (done) settle();
else place(0);
};
const pick = (t: (typeof TABS)[number]) => {
setDir(TABS.indexOf(t) - TABS.indexOf(tab));
setTab(t);
};
const you = members[0];
const to = debt && members.find((m) => m.name === debt.to);
return (
<div className="gu-split">
<header className="gu-split__top">
<p className="gu-split__eyebrow">Shared costs</p>
<h2 className="gu-split__title">{group}</h2>
<div className="gu-split__meta">
<span className="gu-split__faces" aria-hidden="true">
{members.map((m, i) => (
<span
key={m.name}
style={{ background: m.color, "--i": i } as CSSProperties}
>
{initials(m.name)}
</span>
))}
</span>
<span>
<Money value={total} currency={currency} /> spent ·{" "}
<Money value={share} currency={currency} /> each
</span>
</div>
</header>
<div className="gu-split__tabs" role="tablist" aria-label="View">
{TABS.map((t) => (
<button
key={t}
type="button"
role="tab"
aria-selected={tab === t}
onClick={() => pick(t)}
>
{t === "balances" ? "Balances" : "Expenses"}
</button>
))}
<span
className="gu-split__pill"
data-right={tab === "expenses"}
aria-hidden="true"
/>
</div>
<div className="gu-split__panel">
<div
key={tab}
className="gu-split__sheet"
data-dir={dir > 0 ? "left" : dir < 0 ? "right" : "none"}
>
{tab === "balances" ? (
<ul className="gu-split__balances" aria-label="Balances">
{members.map((m, i) => (
<BalanceRow
key={m.name}
m={m}
widest={widest}
currency={currency}
flash={flash.includes(m.name)}
index={i}
/>
))}
</ul>
) : (
<ul className="gu-split__expenses" aria-label="Expenses">
{expenses.map((e, i) => (
<li key={e.title} style={{ "--i": i } as CSSProperties}>
<span className="gu-split__kind" aria-hidden="true">
{e.kind}
</span>
<span className="gu-split__what">
<strong>{e.title}</strong>
<span>
{e.by === you.name ? "You" : e.by} paid · {e.date}
</span>
</span>
<span className="gu-split__cost">
<strong>{money(e.amount)}</strong>
<span>your share {money(e.amount / members.length)}</span>
</span>
</li>
))}
</ul>
)}
</div>
</div>
{/* Settle up */}
<section
className="gu-split__settle"
data-settled={settled}
data-empty={!debt}
aria-live="polite"
>
{debt && to ? (
<>
<p className="gu-split__owe">
<span className="gu-split__owe-text" key={String(settled)}>
{settled ? (
<>Settled with {to.name}</>
) : (
<>
You owe <strong>{to.name}</strong>
</>
)}
</span>
<span className="gu-split__owe-amount">
<Money value={settled ? 0 : debt.amount} currency={currency} />
</span>
</p>
<div ref={track} className="gu-split__track">
<span className="gu-split__fill" aria-hidden="true" />
<span className="gu-split__label" aria-hidden="true">
{settled ? "Settled" : "Slide to settle up"}
</span>
<span className="gu-split__chevrons" aria-hidden="true">
<i />
<i />
<i />
</span>
<button
ref={thumb}
type="button"
className="gu-split__thumb"
aria-label={`Settle up ${money(debt.amount)} with ${to.name}`}
onPointerDown={down}
onPointerMove={move}
onPointerUp={up}
onPointerCancel={up}
// A keyboard press (Enter or Space) gives a click with detail 0; mouse and touch must slide.
onClick={(e) => e.detail === 0 && settle()}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
{settled ? (
<path
className="gu-split__check"
pathLength={1}
d="m5 12.5 4.5 4.5L19 7.5"
/>
) : (
<path
className="gu-split__arrow"
d="M5 12h13M13 6l6 6-6 6"
/>
)}
</svg>
</button>
</div>
{burst > 0 && settled && (
<span className="gu-split__coins" key={burst} aria-hidden="true">
{Array.from({ length: COINS }, (_, i) => {
const a =
-Math.PI / 2 +
((i / (COINS - 1)) * 1.6 - 0.8) * Math.PI * 0.75;
const d = 70 + ((i * 37) % 60);
return (
<i
key={i}
style={
{
"--dx": `${Math.cos(a) * d}px`,
"--dy": `${Math.sin(a) * d}px`,
"--rot": `${((i * 53) % 360) - 180}deg`,
"--delay": `${(i % 5) * 30}ms`,
} as CSSProperties
}
/>
);
})}
</span>
)}
</>
) : (
<p className="gu-split__square">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="10" pathLength={1} />
<path d="m7.5 12.5 3 3 6-6.5" pathLength={1} />
</svg>
You’re all square. Nice.
</p>
)}
</section>
</div>
);
}
```
### split-bills.css
```css
/* SplitBills: clean paper, ink, green for money coming back, orange for money owed. */
.gu-split {
--bg: #f3f3ef;
--card: #ffffff;
--ink: #141414;
--muted: #6d6d68;
--line: rgb(20 20 20 / 0.09);
--gets: #0d8f6f;
--owes: #ff5a1f;
--focus: #2b35ff;
--ease: cubic-bezier(0.16, 1, 0.3, 1);
--spring: cubic-bezier(0.34, 1.4, 0.5, 1);
position: relative;
display: flex;
flex-direction: column;
height: 100%;
min-height: 640px;
overflow: hidden;
padding: calc(var(--gu-safe-top, env(safe-area-inset-top, 0px)) + 10px) 18px
calc(var(--gu-safe-bottom, env(safe-area-inset-bottom, 0px)) + 12px);
background: var(--bg);
color: var(--ink);
font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
-webkit-font-smoothing: antialiased;
}
.gu-split button {
font: inherit;
color: inherit;
border: 0;
background: none;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.gu-split :focus-visible {
outline: 2px solid var(--focus);
outline-offset: 2px;
}
.gu-split__eyebrow {
margin: 0;
font-size: 14px;
color: var(--muted);
}
.gu-split__title {
margin: 2px 0 0;
font-size: 30px;
font-weight: 750;
letter-spacing: -0.03em;
line-height: 1.05;
}
.gu-split__meta {
display: flex;
align-items: center;
gap: 10px;
margin-top: 10px;
font-size: 13px;
font-weight: 600;
color: var(--muted);
}
.gu-split__faces {
display: flex;
}
.gu-split__faces span,
.gu-split__face {
display: grid;
place-items: center;
width: 28px;
height: 28px;
border-radius: 50%;
color: #fff;
font-size: 12px;
font-weight: 700;
box-shadow: 0 0 0 2px var(--bg);
}
.gu-split__faces span {
animation: gu-split-pop 0.6s var(--spring) both;
animation-delay: calc(var(--i) * 70ms + 100ms);
}
.gu-split__faces span + span {
margin-left: -7px;
}
@keyframes gu-split-pop {
from {
opacity: 0;
scale: 0.3;
}
}
.gu-split__num {
font-variant-numeric: tabular-nums;
}
/* Tabs: a white pill glides under the chosen one. */
.gu-split__tabs {
position: relative;
display: grid;
grid-template-columns: 1fr 1fr;
margin-top: 16px;
padding: 4px;
border-radius: 999px;
background: rgb(20 20 20 / 0.06);
}
.gu-split__tabs button {
position: relative;
z-index: 1;
min-height: 40px;
border-radius: 999px;
font-size: 15px !important;
font-weight: 650 !important;
color: var(--muted) !important;
transition: color 0.3s;
}
.gu-split__tabs button[aria-selected="true"] {
color: var(--ink) !important;
}
.gu-split__pill {
position: absolute;
top: 4px;
bottom: 4px;
left: 4px;
width: calc(50% - 4px);
border-radius: 999px;
background: var(--card);
box-shadow:
0 1px 1px rgb(20 20 20 / 0.06),
0 4px 12px rgb(20 20 20 / 0.1);
transition: translate 0.55s var(--spring);
}
.gu-split__pill[data-right="true"] {
translate: 100% 0;
}
.gu-split__panel {
flex: 1;
min-height: 0;
margin: 14px -18px 0;
padding: 0 18px 12px;
overflow-x: hidden;
overflow-y: auto;
scrollbar-width: none;
}
/* The new tab slides in from the side you moved towards. */
.gu-split__sheet[data-dir="left"] {
animation: gu-split-from-right 0.5s var(--ease) both;
}
.gu-split__sheet[data-dir="right"] {
animation: gu-split-from-left 0.5s var(--ease) both;
}
@keyframes gu-split-from-right {
from {
opacity: 0;
translate: 40px 0;
}
}
@keyframes gu-split-from-left {
from {
opacity: 0;
translate: -40px 0;
}
}
.gu-split__balances,
.gu-split__expenses {
margin: 0;
padding: 4px 14px;
list-style: none;
border-radius: 24px;
background: var(--card);
box-shadow:
0 1px 0 var(--line),
0 18px 30px -26px rgb(20 20 20 / 0.45);
}
.gu-split__balances li,
.gu-split__expenses li {
position: relative;
display: grid;
align-items: center;
min-height: 64px;
animation: gu-split-row 0.55s var(--ease) both;
animation-delay: calc(var(--i) * 60ms);
}
@keyframes gu-split-row {
from {
opacity: 0;
translate: 0 10px;
}
}
.gu-split__balances li + li,
.gu-split__expenses li + li {
border-top: 1px solid var(--line);
}
/* Balances: a bar from the middle line, right for "gets back", left for "owes". */
.gu-split__balances li {
grid-template-columns: 1fr 1fr;
grid-template-areas: "who amount" "bar bar";
row-gap: 8px;
padding: 12px 0;
}
/* The two people in a settlement light up for a moment. */
.gu-split__balances li[data-flash="true"]::before {
content: "";
position: absolute;
inset: 2px -8px;
border-radius: 14px;
background: rgb(13 143 111 / 0.1);
animation: gu-split-flash 2.2s var(--ease) both;
pointer-events: none;
}
@keyframes gu-split-flash {
0% {
opacity: 0;
scale: 0.96;
}
15% {
opacity: 1;
scale: 1;
}
100% {
opacity: 0;
}
}
.gu-split__who {
grid-area: who;
display: flex;
align-items: center;
gap: 10px;
font-size: 15px;
font-weight: 650;
}
.gu-split__amount {
grid-area: amount;
justify-self: end;
font-size: 14px;
font-weight: 650;
font-variant-numeric: tabular-nums;
transition: color 0.5s;
}
li[data-side="gets"] .gu-split__amount {
color: var(--gets);
}
li[data-side="owes"] .gu-split__amount {
color: var(--owes);
}
li[data-side="even"] .gu-split__amount {
color: var(--muted);
}
.gu-split__bar {
grid-area: bar;
position: relative;
height: 8px;
border-radius: 4px;
background: rgb(20 20 20 / 0.05);
}
.gu-split__bar::before {
content: "";
position: absolute;
left: 50%;
top: -3px;
bottom: -3px;
width: 2px;
margin-left: -1px;
border-radius: 1px;
background: rgb(20 20 20 / 0.25);
}
.gu-split__bar span {
position: absolute;
top: 0;
bottom: 0;
width: calc(var(--k) * 50%);
border-radius: 4px;
transition:
width 1s var(--spring),
background-color 0.4s;
/* "backwards" so later width changes still use the transition. */
animation: gu-split-grow 0.9s var(--spring) backwards;
animation-delay: calc(var(--i, 0) * 70ms + 150ms);
}
@keyframes gu-split-grow {
from {
width: 0;
}
}
li[data-side="gets"] .gu-split__bar span {
left: 50%;
background: linear-gradient(90deg, #12a580, var(--gets));
box-shadow: 0 0 10px rgb(13 143 111 / 0.35);
}
li[data-side="owes"] .gu-split__bar span {
right: 50%;
background: linear-gradient(270deg, #ff7a45, var(--owes));
box-shadow: 0 0 10px rgb(255 90 31 / 0.35);
}
/* Expenses */
.gu-split__expenses li {
grid-template-columns: 42px 1fr auto;
gap: 12px;
padding: 10px 0;
}
.gu-split__kind {
display: grid;
place-items: center;
width: 42px;
height: 42px;
border-radius: 14px;
background: rgb(20 20 20 / 0.05);
font-size: 20px;
}
.gu-split__what,
.gu-split__cost {
display: grid;
gap: 2px;
min-width: 0;
}
.gu-split__what strong,
.gu-split__cost strong {
font-size: 15px;
font-weight: 650;
}
.gu-split__what span,
.gu-split__cost span {
font-size: 12px;
color: var(--muted);
}
.gu-split__cost {
text-align: right;
font-variant-numeric: tabular-nums;
}
/* Settle card */
.gu-split__settle {
position: relative;
padding: 16px;
border-radius: 28px;
background:
radial-gradient(
120% 140% at 100% 0%,
rgb(255 255 255 / 0.08),
transparent 50%
),
var(--ink);
color: #fff;
box-shadow: 0 20px 40px -20px rgb(20 20 20 / 0.6);
transition: background-color 0.5s;
}
.gu-split__settle[data-settled="true"] {
background:
radial-gradient(
120% 140% at 100% 0%,
rgb(255 255 255 / 0.18),
transparent 50%
),
var(--gets);
animation: gu-split-thump 0.6s var(--spring);
}
@keyframes gu-split-thump {
30% {
scale: 1.025;
}
}
.gu-split__owe {
display: flex;
align-items: baseline;
justify-content: space-between;
margin: 2px 4px 14px;
font-size: 15px;
color: rgb(255 255 255 / 0.75);
}
.gu-split__owe-text {
animation: gu-split-swap 0.5s var(--ease) both;
}
@keyframes gu-split-swap {
from {
opacity: 0;
translate: 0 8px;
filter: blur(4px);
}
}
.gu-split__owe strong {
color: #fff;
}
.gu-split__owe-amount {
font-size: 26px;
font-weight: 750;
letter-spacing: -0.02em;
color: #fff;
}
.gu-split__track {
--x: 0px;
--fill: 0;
position: relative;
height: 64px;
border-radius: 999px;
background: rgb(255 255 255 / 0.1);
box-shadow: inset 0 2px 6px rgb(0 0 0 / 0.35);
overflow: hidden;
}
/* Green fill that trails the thumb, so the slide feels like pouring. */
.gu-split__fill {
position: absolute;
inset: 4px auto 4px 4px;
width: calc(var(--x) + 56px);
border-radius: 999px;
background: linear-gradient(
90deg,
rgb(13 143 111 / 0.25),
rgb(18 180 140 / 0.9)
);
opacity: calc(var(--fill) * 1.5);
transition:
width 0.55s var(--spring),
opacity 0.4s;
}
.gu-split__label {
position: absolute;
inset: 0;
display: grid;
place-items: center;
padding-left: 40px;
font-size: 16px;
font-weight: 650;
/* The words shine from left to right, asking to be slid. */
background: linear-gradient(
90deg,
rgb(255 255 255 / 0.4) 30%,
#fff 50%,
rgb(255 255 255 / 0.4) 70%
)
0 0 / 300% 100%;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: gu-split-shine 2.4s linear infinite;
opacity: calc(1 - var(--fill) * 1.6);
}
@keyframes gu-split-shine {
from {
background-position: 100% 0;
}
to {
background-position: -50% 0;
}
}
.gu-split__chevrons {
position: absolute;
right: 22px;
top: 50%;
display: flex;
gap: 2px;
translate: 0 -50%;
opacity: calc(1 - var(--fill) * 2);
}
.gu-split__chevrons i {
width: 8px;
height: 8px;
border-top: 2px solid #fff;
border-right: 2px solid #fff;
rotate: 45deg;
opacity: 0.2;
animation: gu-split-chev 1.4s ease-in-out infinite;
}
.gu-split__chevrons i:nth-child(2) {
animation-delay: 0.15s;
}
.gu-split__chevrons i:nth-child(3) {
animation-delay: 0.3s;
}
@keyframes gu-split-chev {
40% {
opacity: 0.9;
}
}
.gu-split__settle[data-settled="true"] .gu-split__label {
opacity: 1;
padding: 0 64px 0 0;
animation: gu-split-swap 0.5s var(--ease) both;
background: none;
color: #fff;
}
.gu-split__settle[data-settled="true"] .gu-split__chevrons {
opacity: 0;
}
.gu-split__thumb {
position: absolute;
top: 4px;
left: 4px;
z-index: 2;
display: grid;
place-items: center;
width: 56px;
height: 56px;
border-radius: 50%;
background: radial-gradient(circle at 35% 30%, #fff, #e9e9e4) !important;
color: var(--ink) !important;
box-shadow:
0 6px 16px rgb(0 0 0 / 0.35),
inset 0 -2px 3px rgb(0 0 0 / 0.08);
translate: var(--x) 0;
transition:
translate 0.55s var(--spring),
scale 0.25s var(--ease);
touch-action: none;
cursor: grab;
}
.gu-split__track[data-dragging="true"] .gu-split__thumb {
scale: 1.06;
cursor: grabbing;
}
.gu-split__track[data-dragging="true"] .gu-split__thumb,
.gu-split__track[data-dragging="true"] .gu-split__fill {
transition: scale 0.25s var(--ease);
}
.gu-split__settle[data-settled="true"] .gu-split__thumb {
color: var(--gets) !important;
}
.gu-split__thumb svg {
width: 24px;
height: 24px;
fill: none;
stroke: currentColor;
stroke-width: 2.4;
stroke-linecap: round;
stroke-linejoin: round;
overflow: visible;
}
/* The arrow nudges right now and then: "this way". */
.gu-split__arrow {
animation: gu-split-nudge 2.4s var(--ease) infinite;
}
@keyframes gu-split-nudge {
0%,
60%,
100% {
translate: 0 0;
}
70% {
translate: 4px 0;
}
80% {
translate: 0 0;
}
88% {
translate: 3px 0;
}
}
.gu-split__check {
stroke-dasharray: 1;
stroke-dashoffset: 1;
animation: gu-split-draw 0.45s 0.15s var(--ease) forwards;
}
@keyframes gu-split-draw {
to {
stroke-dashoffset: 0;
}
}
/* Coins burst out of the end of the track. */
.gu-split__coins {
position: absolute;
right: 44px;
bottom: 48px;
z-index: 3;
pointer-events: none;
}
.gu-split__coins i {
position: absolute;
width: 14px;
height: 14px;
margin: -7px;
border-radius: 50%;
background: radial-gradient(circle at 35% 30%, #fff4c4, #f2c14e 45%, #b8861b);
box-shadow: inset 0 0 0 1.5px rgb(150 100 10 / 0.5);
opacity: 0;
animation: gu-split-coin 1.1s var(--delay) cubic-bezier(0.2, 0.7, 0.3, 1)
forwards;
}
@keyframes gu-split-coin {
0% {
opacity: 1;
translate: 0 0;
scale: 0.4;
}
60% {
opacity: 1;
scale: 1;
}
100% {
opacity: 0;
translate: var(--dx) calc(var(--dy) + 40px);
rotate: var(--rot);
scale: 0.8;
}
}
.gu-split__square {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
margin: 0;
padding: 18px 4px;
font-size: 17px;
font-weight: 650;
animation: gu-split-swap 0.6s var(--ease) both;
}
.gu-split__square svg {
width: 28px;
height: 28px;
fill: none;
stroke: #7fe0bd;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.gu-split__square circle,
.gu-split__square path {
stroke-dasharray: 1;
stroke-dashoffset: 1;
animation: gu-split-draw 0.7s var(--ease) forwards;
}
.gu-split__square path {
animation-delay: 0.4s;
}
@media (prefers-reduced-motion: reduce) {
.gu-split *,
.gu-split__settle {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
animation-delay: 0ms !important;
transition-duration: 0.01ms !important;
}
.gu-split__label {
background: none;
color: #fff;
}
.gu-split__coins {
display: none;
}
}
```
You might also want
Next piece: Strength gym landing pageLiquid glass tab bar app
Apps, advanced
Boarding pass app
Apps, intermediate
Run tracker app
Apps, advanced