Seat manager
Team seats and billing card with member avatars, segmented seat meter, press-and-hold stepper with live prorated quote, two-step confirm-and-pay footer, full-capacity prompts, and pending invites with resend and undoable revoke.
import { SeatManager } from '@uthereal/ui/seat-manager'Seat manager playground
Seats
ProFieldnote Studio · $16 per seat/mo · Renews Nov 25
- Due todayNo change
- $0.00
- From Nov 25Current total
- $192.00/mo
- jordan.blake@fieldnote.example
- priya.shah@harborline.studio
Overview
SeatManager combines seat usage, subscription quantity changes, and pending invite management in one billing card. The top section displays member avatars (first four plus a +N counter), a segmented seat meter distinguishing members, pending invites, open seats, and seats being added or removed, a text legend, and a contextual notice line that surfaces a one-tap Add a seat shortcut whenever capacity is full.
Below usage, a press-and-hold stepper updates the target seat count while rolling the prorated Due today charge and recurring renewal total live via buildSeatQuote. Pending invites reserve seats and can be resent or revoked with a timed Undo window (undoSeconds, default 3s). Pressing Update seats opens an inline confirmation step (Back / Confirm & pay) before any charge runs.
Use SeatManager on workspace billing and team settings pages for per-seat subscriptions. For initial subscription checkout with plan selection and payment fields, use Live checkout. For prepaid credit balances and auto top-ups, use Credit top-up.
Usage
'use client'
import { SeatManager, buildSeatQuote } from '@uthereal/ui/seat-manager'
export function TeamSeats({
workspace,
seats,
members,
invites,
period,
}: {
workspace: string
seats: number
members: { id: string; name: string; avatar?: string }[]
invites: { id: string; email: string; invitedBy?: string; note?: string }[]
period: { start: string; end: string }
}) {
return (
<SeatManager
workspace={workspace}
plan={{ name: 'Pro', pricePerSeat: 16, interval: 'month', maxSeats: 25 }}
purchased={seats}
members={members}
invites={invites}
period={period}
now={new Date()}
paymentMethod={{ brand: 'Visa', last4: '4242' }}
receiptEmail="billing@northwind.example"
updateSeats={async (quote, signal) => {
const res = await fetch('/api/billing/seats', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ seats: quote.target }),
signal,
})
if (!res.ok) {
throw new Error('Your card was declined. Nothing was charged.')
}
}}
resendInvite={async (invite, signal) => {
await fetch(`/api/invites/${invite.id}/resend`, {
method: 'POST',
signal,
})
}}
revokeInvite={async (invite, signal) => {
await fetch(`/api/invites/${invite.id}`, {
method: 'DELETE',
signal,
})
}}
/>
)
}Omit updateSeats, resendInvite, and revokeInvite (and host actions) to run the built-in local simulation (nothing is charged or emailed; autoPlay loops through adding seats, confirming, resending, and revoking until any pointer or key press inside the card). Import buildSeatQuote on the server to verify the exact same proration math.
Examples
Open capacity on annual EUR billing
Configure purchased above memberCount + invites.length with an annual EUR plan and autoPlay: false to show open seats, healthy capacity status, and zero-due-today removals that take effect at renewal.
Seats
BusinessNordlicht Studio · 192 € per seat/yr · Renews 1. Jan.
- Due todayNo change
- 0,00 €
- From 1. Jan.Current total
- 2.688,00 €/yr
- sofia.lind@nordlicht.example
Grouped meter at full capacity
When total seats exceed 40, the seat meter switches automatically to proportional grouped segments (data-grouped), while full capacity (48 of 48 seats used) surfaces the warning notice and one-tap Add a seat action.
Seats
EnterpriseNorthwind Enterprise · $32 per seat/mo · Renews Nov 25
- Due todayNo change
- $0.00
- From Nov 25Current total
- $1,536.00/mo
- sam.rivera@northwind.example
- maya.okafor@northwind.example
- noah.chen@northwind.example
Proration, seat meter, and footer phases
Proration math (buildSeatQuote)
| Field | Formula |
|---|---|
periodDays | max(1, round((end - start) / 86_400_000)) whole days in the billing period. |
daysLeft | ceil((end - now) / 86_400_000) clamped to [0, periodDays]. |
dueToday | When delta > 0: round(delta × pricePerSeat × (daysLeft / periodDays), 2). When delta ≤ 0: 0. |
nextTotal | round(target × pricePerSeat, 2) billed per interval starting on renewsOn. |
Footer confirmation lifecycle
| Phase | Left slot | Right slot |
|---|---|---|
idle | Saved payment method (or live delta summary if dirty). | Update seats (disabled when clean). |
confirm | "Charge {amount} to {card} now?" or removal prompt. | Back + Confirm & pay (or Confirm). |
saving | Pulsing "Charging {card}" or "Updating seats". | Disabled Back + loading button. |
done | Success icon + "Now on {count} seats. Receipt sent…". | Update seats (disabled). |
error | Danger icon + rejected Error.message. | Back + Try again. |
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Seats" | Card heading and accessible section name. |
workspace | stringDefault: "Fieldnote Studio" | Workspace name shown under the title. |
plan | SeatPlanDefault: {"name":"Pro","pricePerSeat":16,"interval":"month","currency":"USD","maxSeats":25} | Subscription plan: name, seat price in major units, billing interval, ISO currency, and an optional seat cap. |
purchased | integerDefault: 12 | Seats paid for right now; becomes the new count after a successful update. |
members | SeatMember[]Default: [{"id":"emma","name":"Emma Collins"},{"id":"nathan","name":"Nathan Cole"},{"id":"jasmine","name":"Jasmine Brooks"},{"id":"daniel","name":"Daniel Kim"},{"id":"olivia","name":"Olivia Bennett"},{"id":"marcus","name":"Marcus Johnson"},{"id":"chloe","name":"Chloe Nguyen"},{"id":"sofia","name":"Sofia Ramirez"},{"id":"mateo","name":"Mateo Alvarez"},{"id":"hannah","name":"Hannah Walsh"}] | Members holding a seat. The first four show as avatars, the rest as a +N count. |
memberCount | integer— | Total members when members is only a sample for the avatars. Defaults to members.length. |
invites | SeatInvite[]Default: [{"id":"jordan","email":"jordan.blake@fieldnote.example","invitedBy":"Emma Collins","note":"2 days ago"},{"id":"priya","email":"priya.shah@harborline.studio","invitedBy":"Nathan Cole","note":"expires soon"}] | Pending invites. Each reserves a seat until it is accepted or revoked. |
period | SeatPeriodDefault: {"start":"2026-10-26T00:00:00Z","end":"2026-11-25T00:00:00Z"} | Current billing period. Added seats are prorated by the days left; the new total starts at the end date. |
now | string— | "Today" for proration. Defaults to a fixed sample date so server markup is deterministic. |
paymentMethod | SeatPaymentMethodDefault: {"brand":"Visa","last4":"4242"} | Card the charge goes to, named in the footer and the confirm step. Pass null to hide it. |
receiptEmail | stringDefault: "billing@fieldnote.example" | Where receipts go, named in the done message. |
undoSeconds | integerDefault: 3 | How long Undo stays on a revoked invite, in seconds. |
autoPlay | booleanDefault: true | Play the simulated loop until a pointer or key press inside the card. Ignored when any host handler is wired. |
updateSeatsAction | string— | Registered host action requested when the two-step update is confirmed; receives the seat quote. |
resendInviteAction | string— | Registered host action requested when an invite is resent. |
revokeInviteAction | string— | Registered host action requested when a revoked invite settles, after the undo window. |
updateSeatsLabel | stringDefault: "Update seats" | Label of the primary footer button. |
confirmPayLabel | stringDefault: "Confirm & pay" | Label of the confirm footer button. |
backLabel | stringDefault: "Back" | Label canceling the confirm step. |
tryAgainLabel | stringDefault: "Try again" | Label of the confirm button after an error. |
addSeatLabel | stringDefault: "Add a seat" | One-tap action in the full-capacity notice. |
removeSeatLabel | stringDefault: "Remove a seat" | Accessible name of the minus stepper button. |
addOneSeatLabel | stringDefault: "Add a seat" | Accessible name of the plus stepper button. |
removeSeatPrompt | stringDefault: "Remove {count} seat{plural} on {date}?" | Confirm-step question for removals; {count}, {plural} and {date} fill in. |
seatsLabel | stringDefault: "Seats" | Accessible name of the stepper count. |
seatsUsedLabel | stringDefault: "{used} of {purchased} seats used" | Usage line; {used} and {purchased} fill in. |
seatsUsedDetailLabel | stringDefault: "{used} of {purchased} seats used: {members} members, {invited} invited, {open} open, {delta} being added" | Full seat-meter text while seats are added. |
seatsOpenDetailLabel | stringDefault: "{used} of {purchased} seats used: {members} members, {invited} invited, {open} open, {delta} being removed" | Full seat-meter text while seats are removed. |
seatsUsedSameDetailLabel | stringDefault: "{used} of {purchased} seats used: {members} members, {invited} invited, {open} open" | Full seat-meter text at rest. |
membersLabel | stringDefault: "{count} members" | Avatar stack label; {count} fills the member total. |
membersLegendLabel | stringDefault: "{count} members" | Legend item for members. |
invitedLabel | stringDefault: "{count} invited" | Legend item for invited seats. |
openLabel | stringDefault: "{count} open" | Legend item for open seats. |
newLabel | stringDefault: "{count} new" | Legend item while seats are added. |
removedLabel | stringDefault: "{count} removed" | Legend item while seats are removed. |
purchasedLabel | stringDefault: "{count} purchased" | Stepper meta line; {count} fills the paid count. |
dueTodayLabel | stringDefault: "Due today" | Quote row label for the prorated charge. |
proratedForLabel | stringDefault: "Prorated for {count} day{plural}" | Due-today note while adding; {count} fills days left. |
removalsApplyLabel | stringDefault: "Removals apply on {date}" | Due-today note while removing; {date} fills in. |
noChangeLabel | stringDefault: "No change" | Due-today note at rest. |
fromLabel | stringDefault: "From {date}" | Quote row label for the new total; {date} fills in. |
wasLabel | stringDefault: "Was {amount}" | New-total note while dirty; {amount} fills in. |
currentTotalLabel | stringDefault: "Current total" | New-total note at rest. |
pendingInvitesLabel | stringDefault: "Pending invites" | Heading of the pending invites section. |
invitedByLabel | stringDefault: "Invited by {name}" | Invite meta line; {name} fills the inviter. |
resendLabel | stringDefault: "Resend" | Label of each invite resend action. |
resendToLabel | stringDefault: "Resend invite to {email}" | Accessible name of each resend action. |
sentLabel | stringDefault: "Sent" | Resend action label after it completes. |
sentToLabel | stringDefault: "Invite sent to {email}" | Accessible name after a resend completes. |
revokeLabel | stringDefault: "Revoke" | Label of each invite revoke action. |
revokeLabelWithEmail | stringDefault: "Revoke invite to {email}" | Accessible name of each revoke action. |
undoLabel | stringDefault: "Undo" | Label restoring a revoked invite. |
inviteRevokedLabel | stringDefault: "Invite revoked, 1 seat freed" | Meta line replacing a revoked invite. |
noPendingInvitesLabel | stringDefault: "No pending invites" | Empty pending list state. |
seatLimitReachedLabel | stringDefault: "Seat limit reached. New invites need a seat." | Warning when every purchased seat is taken. |
seatsOpenLabel | stringDefault: "{count} seat{plural} open for new invites." | Notice at rest with open seats. |
newSeatsOpenLabel | stringDefault: "{count} new seat{plural} open after you update." | Notice while adding seats. |
removedSeatsLabel | stringDefault: "{count} open seat{plural} removed on {date}." | Notice while removing seats. |
minSeatsLabel | stringDefault: "{count} seats are taken. Revoke an invite to go lower." | Notice when stepping below the minimum, with invites. |
minSeatsNoInvitesLabel | stringDefault: "{count} seats are taken. Remove a member to go lower." | Notice when stepping below the minimum. |
maxSeatsLabel | stringDefault: "{name} includes up to {count} seats. Contact sales for more." | Notice at the plan cap. |
chargingLabel | stringDefault: "Charging {card}" | Saving footer text while adding; {card} fills in. |
updatingSeatsLabel | stringDefault: "Updating seats" | Saving footer text while removing. |
doneLabel | stringDefault: "Now on {count} seats. Receipt sent to {email}." | Done footer text; {count} and {email} fill in. |
chargeConfirmLabel | stringDefault: "Charge {amount} to {card} now?" | Confirm-step question while adding. |
noCardLabel | stringDefault: "your card" | Fallback card name when paymentMethod is null. |
billingNoteLabel | stringDefault: "Billed via Stripe" | Idle footer note beside the card. |
noChangesLabel | stringDefault: "No changes" | Idle footer text without a payment method. |
deltaSeatsLabel | stringDefault: "{count} seat{plural}" | Footer seat count while dirty; {count} fills in. |
dueTodayFooterLabel | stringDefault: "{seats}, {amount} due today" | Footer while adding; {seats} and {amount} fill in. |
renewalFooterLabel | stringDefault: "{seats} from {date}, nothing due today" | Footer while removing; {seats} and {date} fill in. |
simulatedNoteLabel | stringDefault: "Simulated, {what}." | Suffix appended to announcements when no host handlers are wired; {what} fills in. |
reviewAddedLabel | stringDefault: "Review: {seats} added, {amount} due today." | Announcement opening the confirm step for additions. |
reviewRemovedLabel | stringDefault: "Review: {seats} removed on {date}." | Announcement opening the confirm step for removals. |
updatedLabel | stringDefault: "Updated to {count} seats." | Announcement after a successful update. |
chargedLabel | stringDefault: "{amount} charged." | Announcement suffix after a paid update. |
resentAnnouncementLabel | stringDefault: "Invite sent again to {email}." | Announcement after a resend. |
revokedAnnouncementLabel | stringDefault: "Invite to {email} revoked, 1 seat freed. Undo is available for {seconds} seconds." | Announcement after a revoke. |
restoredLabel | stringDefault: "Invite to {email} restored." | Announcement after undoing a revoke. |
removedInviteLabel | stringDefault: "Invite to {email} removed." | Announcement after a revoked invite settles. |
resendFailedLabel | stringDefault: "Could not resend the invite to {email}." | Announcement after a failed resend. |
revokeFailedLabel | stringDefault: "Could not revoke the invite to {email}. It is still pending." | Announcement after a failed revoke. |
paymentFailedLabel | stringDefault: "Payment failed. Nothing was charged." | Footer error text when updateSeats rejects without a message. |
locale | string— | BCP 47 locale for money and dates; inherited when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | SeatManagerThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | SeatManagerMotionOptionsDefault: {} | Cell growth, copy swap and row timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
SeatPlanaccepts{ name, pricePerSeat, interval: 'month' | 'year', currency, maxSeats? }, withpricePerSeatin major currency units (for example16for$16.00).SeatMemberaccepts{ id, name, avatar? };SeatInviteaccepts{ id, email, invitedBy?, note? }. Member and invite IDs must be unique.SeatPeriodaccepts{ start, end }as ISO date strings;SeatPaymentMethodaccepts{ brand, last4 }ornullto hide the card line.
React integration
| Prop | Purpose |
|---|---|
now | Overrides "today" for proration (ISO string or Date). Defaults to a fixed sample date (2026-11-15) for deterministic SSR. |
updateSeats(quote, signal) | Persists the seat change with an abortable AbortSignal. Reject with an Error to display its message and Try again. |
resendInvite(invite, sig) | Resends the invite email; transitions the row button from loading spinner to Sent. |
revokeInvite(invite, sig) | Runs after undoSeconds elapse without Undo; reject to restore the invite automatically. |
onQuoteChange(quote) | Called whenever the stepper recalculates SeatQuote. |
onSeatsChange(seats, q) | Called after a seat update resolves with the new purchased count and quote. |
onPhaseChange(phase) | Called on every footer phase transition (idle, confirm, saving, done, error). |
onAction(action, itemId?) | Called for updateSeatsAction, resendInviteAction (with invite ID), and revokeInviteAction (with invite ID). |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme, forwarded to the root card and composed Button and Avatar children. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root element. |
Keyboard & accessibility
| Key | Action |
|---|---|
Tab | Moves through the stepper buttons, spinbutton, invite actions, and footer buttons. |
ArrowUp / ArrowRight | On the seat count spinbutton, adds one seat. |
ArrowDown / ArrowLeft | On the seat count spinbutton, removes one seat down to members + pending invites. |
PageUp / PageDown | Changes the seat count by 5 seats within plan bounds. |
Home / End | Jumps to the minimum occupied seats or plan.maxSeats. |
Enter / Space | Activates buttons; pressing Update seats moves focus to confirm, Back returns focus. |
- The seat count exposes
role="spinbutton"witharia-valuemin,aria-valuemax,aria-valuenow, and spokenaria-valuetext. - Pressing past the minimum or plan maximum keeps the stepper button focusable (
aria-disabled="true") and explains the limit in the notice line rather than disabling silently. - The seat meter exposes
role="img"with a complete count breakdown, and the legend repeats every count in text so color is never the only signal. - Every rolling number pairs
aria-hidden="true"glyphs with a visually hidden full text value, and every invite button carries an address-specificaria-label. - A polite
role="status"live region announces review prompts, completed updates, resends, revokes with their undo window, restores, and failures (staying silent whileautoPlayruns). - Container queries tighten padding and omit secondary quote notes below
460px, and drop the delta legend item below340px. Logical CSS properties mirror cleanly in RTL (dir="rtl"), and@media (forced-colors: active)preserves meter fills, badges, links, and focus outlines.
Motion & theming
Seat meter cells grow and shrink smoothly on a zero-bounce smooth spring with symmetric inline padding so neighboring cells glide into place. Pending invite rows collapse and reopen on the same bounce-free height spring, numbers roll in tabular slots, and footer/notice copy crossfades in shared grid cells without shifting card height. Press-and-hold on stepper buttons repeats after 380ms and then every 70ms.
Under prefers-reduced-motion: reduce, cell growth, height springs, digit rolls, and saving shimmer turn off while crossfades shorten to 120ms opacity fades. Setting motion="none" makes every transition immediate (0ms).
theme accepts mode, accent, and typed tokens across these groups:
| Token group | CSS custom properties |
|---|---|
core | --ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-shadow, --ui-disabled-opacity, --ui-font, --ui-font-size, --ui-font-weight |
extended | --ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-track, --ui-info, --ui-success, --ui-warning, --ui-tone-foreground, --ui-overlay, --ui-tint-strength |
shape | --ui-radius-sm, --ui-popup-radius, --ui-surface-radius |
control | --ui-control-height, --ui-control-padding-x, --ui-control-gap, --ui-icon-size |
accentTones | --ui-accent-strong, --ui-accent-subtle |
An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, SeatManager is a leaf block. Keep purchased at or above memberCount + invites.length, supply a real ISO billing period, and wire updateSeatsAction, resendInviteAction, and revokeInviteAction to registered host actions. See Building with agents.
{
"type": "SeatManager",
"props": {
"workspace": "Northwind Studio",
"plan": {
"name": "Pro",
"pricePerSeat": 16,
"interval": "month",
"currency": "USD",
"maxSeats": 25
},
"purchased": 12,
"autoPlay": false,
"updateSeatsAction": "update_workspace_seats",
"resendInviteAction": "resend_seat_invite",
"revokeInviteAction": "revoke_seat_invite"
},
"children": []
}