Composing a screen
What one product screen holds, where its primary action sits and the order each kind of screen reads in.
A Khaeli screen does one job, and each kind of screen reads in a fixed order. The screens below are one invoicing product in miniature, each inside its Budgets. Copy the one nearest your screen as its starting point.
One job, one primary action
Invoices
5 invoices, £4,320.00 outstanding
| Invoice | Customer | Status | Amount |
|---|---|---|---|
| INV-2051 | Brightwater Dental | Overdue | £1,280.00 |
| INV-2050 | Kestrel Print Co | Sent | £640.00 |
| INV-2049 | Oakline Joinery | Sent | £2,400.00 |
| INV-2048 | Pennant Cycles | Paid | £915.00 |
| INV-2047 | Fernhill Bakery | Draft | £350.00 |
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar } from "~/components/principles/screen"
const invoices = [
{ number: "INV-2051", customer: "Brightwater Dental", status: "Overdue", tone: "negative", amount: "£1,280.00" },
{ number: "INV-2050", customer: "Kestrel Print Co", status: "Sent", tone: "info", amount: "£640.00" },
{ number: "INV-2049", customer: "Oakline Joinery", status: "Sent", tone: "info", amount: "£2,400.00" },
{ number: "INV-2048", customer: "Pennant Cycles", status: "Paid", tone: "positive", amount: "£915.00" },
{ number: "INV-2047", customer: "Fernhill Bakery", status: "Draft", tone: "neutral", amount: "£350.00" },
] as const
export default function OneJobOnePrimaryAction() {
return (
<Screen sidebar={<ScreenSidebar current="Invoices" />}>
<ScreenHeader title="Invoices" line="5 invoices, £4,320.00 outstanding" actions={<Button>Create invoice</Button>} />
<ScreenBody rows>
<Table aria-label="Invoices">
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Customer</TableHead>
<TableHead>Status</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.number}>
<TableCell className="font-medium">{invoice.number}</TableCell>
<TableCell>{invoice.customer}</TableCell>
<TableCell>
<Badge variant={invoice.tone}>{invoice.status}</Badge>
</TableCell>
<TableCell className="text-right">{invoice.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</ScreenBody>
</Screen>
)
}
A screen does one job and commits it with one primary action: its only filled button, at the right end of the header. A screen that commits nothing has no filled button.
The header
Customers
5 customers
£1,280.00 outstanding
£640.00 outstanding
£2,400.00 outstanding
Nothing outstanding
Nothing outstanding
import { DownloadIcon, SearchIcon } from "@keyline-icons/react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemSeparator, ItemTitle } from "@/components/ui/item"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar } from "~/components/principles/screen"
const customers = [
{ name: "Brightwater Dental", owes: "£1,280.00 outstanding", tags: ["Care plan", "14 days", "Purchase order"] },
{ name: "Kestrel Print Co", owes: "£640.00 outstanding", tags: ["Project", "14 days"] },
{ name: "Oakline Joinery", owes: "£2,400.00 outstanding", tags: ["Project", "30 days", "Purchase order", "Card on file"] },
{ name: "Pennant Cycles", owes: "Nothing outstanding", tags: ["Care plan", "14 days"] },
{ name: "Fernhill Bakery", owes: "Nothing outstanding", tags: ["Project"] },
]
export default function TheHeader() {
return (
<Screen sidebar={<ScreenSidebar current="Customers" />}>
<ScreenHeader
title="Customers"
line="5 customers"
actions={
<>
<Button variant="ghost" size="icon" aria-label="Search customers">
<SearchIcon />
</Button>
<Button variant="ghost" size="icon" aria-label="Export customers">
<DownloadIcon />
</Button>
<Button variant="outline">Import</Button>
<Button>Add customer</Button>
</>
}
/>
<ScreenBody rows>
<ItemGroup role="list" aria-label="Customers" className="gap-0">
{customers.map(({ name, owes, tags }, index) => (
<div key={name} role="listitem">
{index > 0 ? <ItemSeparator className="my-0" /> : null}
<Item size="sm">
<ItemContent>
<ItemTitle>{name}</ItemTitle>
<ItemDescription>{owes}</ItemDescription>
</ItemContent>
<ItemActions>
{tags.slice(0, 2).map((tag) => (
<Badge key={tag} variant="secondary">
{tag}
</Badge>
))}
{tags.length > 2 ? (
<Badge variant="outline">
+{tags.length - 2}
<span className="sr-only"> more tags</span>
</Badge>
) : null}
</ItemActions>
</Item>
</div>
))}
</ItemGroup>
</ScreenBody>
</Screen>
)
}
A header is a title, at most one line under it, and its actions at the right. It holds at most two labelled actions, the filled one last, and two icon-only ones; more go behind one menu.
A list
Payments
38 payments, £915.00 this month
| Received | Customer | Method | Amount |
|---|---|---|---|
| 18 Nov | Pennant Cycles | Card | £915.00 |
| 30 Oct | Brightwater Dental | Bank transfer | £540.00 |
| 24 Oct | Kestrel Print Co | Card | £1,150.00 |
| 17 Oct | Oakline Joinery | Bank transfer | £760.00 |
| 9 Oct | Brightwater Dental | Bank transfer | £430.00 |
| 2 Oct | Kestrel Print Co | Card | £320.00 |
"use client"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar, ScreenToolbar } from "~/components/principles/screen"
const methods = [
{ value: "all", label: "All methods" },
{ value: "Card", label: "Card" },
{ value: "Bank transfer", label: "Bank transfer" },
]
const payments = [
{ received: "18 Nov", customer: "Pennant Cycles", method: "Card", amount: "£915.00" },
{ received: "30 Oct", customer: "Brightwater Dental", method: "Bank transfer", amount: "£540.00" },
{ received: "24 Oct", customer: "Kestrel Print Co", method: "Card", amount: "£1,150.00" },
{ received: "17 Oct", customer: "Oakline Joinery", method: "Bank transfer", amount: "£760.00" },
{ received: "9 Oct", customer: "Brightwater Dental", method: "Bank transfer", amount: "£430.00" },
{ received: "2 Oct", customer: "Kestrel Print Co", method: "Card", amount: "£320.00" },
]
export default function AList() {
const [method, setMethod] = useState("all")
const shown = payments.filter((payment) => method === "all" || payment.method === method)
return (
<Screen sidebar={<ScreenSidebar current="Payments" />}>
<ScreenHeader title="Payments" line="38 payments, £915.00 this month" actions={<Button>Record payment</Button>} />
<ScreenToolbar actions={<Button variant="outline">Export</Button>}>
<Select items={methods} value={method} onValueChange={(next) => setMethod(next ?? "all")}>
<SelectTrigger aria-label="Method">
<SelectValue />
</SelectTrigger>
<SelectContent>
{methods.map(({ value, label }) => (
<SelectItem key={value} value={value}>
{label}
</SelectItem>
))}
</SelectContent>
</Select>
</ScreenToolbar>
<ScreenBody rows>
<Table aria-label="Payments">
<TableHeader>
<TableRow>
<TableHead>Received</TableHead>
<TableHead>Customer</TableHead>
<TableHead>Method</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{shown.map((payment) => (
<TableRow key={payment.received}>
<TableCell>{payment.received}</TableCell>
<TableCell>{payment.customer}</TableCell>
<TableCell>{payment.method}</TableCell>
<TableCell className="text-right">{payment.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</ScreenBody>
</Screen>
)
}
A list reads title row, at most one toolbar row with filters at its left and an action at its right, then the collection, whose rows part on a hairline with no stripes and no column rules. It shows its count once, beside the title, instead of pages.
A record
INV-2051
OverdueBrightwater Dental, £1,280.00 outstanding
- Issued
- 21 Oct
- Due
- 4 Nov
- Terms
- 14 days
- Order
- PO 4471
- Reminders
- 1 sent
- Paid
- £0.00
- Outstanding
- £1,280.00
1 month
8 hours
Half a day
Total£1,280.00
import { DownloadIcon, ReceiptIcon } from "@keyline-icons/react"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb"
import { Button } from "@/components/ui/button"
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty"
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemSeparator, ItemTitle } from "@/components/ui/item"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar } from "~/components/principles/screen"
const facts = [
{ label: "Issued", value: "21 Oct" },
{ label: "Due", value: "4 Nov" },
{ label: "Terms", value: "14 days" },
{ label: "Order", value: "PO 4471" },
{ label: "Reminders", value: "1 sent" },
{ label: "Paid", value: "£0.00" },
{ label: "Outstanding", value: "£1,280.00" },
]
const lines = [
{ item: "Website care plan, October", quantity: "1 month", amount: "£480.00" },
{ item: "Booking form redesign", quantity: "8 hours", amount: "£640.00" },
{ item: "Photography", quantity: "Half a day", amount: "£160.00" },
]
const activity = [
{ event: "Reminder sent", date: "11 Nov" },
{ event: "Became overdue", date: "5 Nov" },
{ event: "Sent to the customer", date: "21 Oct" },
]
const panel = "-m-2 rounded-md p-2 text-base focus-ring-inset"
export default function ARecord() {
return (
<Screen sidebar={<ScreenSidebar current="Invoices" />}>
<ScreenHeader
trail={
<Breadcrumb aria-label="Path to INV-2051">
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="#one-job-one-primary-action">Invoices</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>INV-2051</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
mark={
<Avatar aria-hidden>
<AvatarFallback>
<ReceiptIcon className="size-4" />
</AvatarFallback>
</Avatar>
}
title="INV-2051"
tag={<Badge variant="negative">Overdue</Badge>}
line="Brightwater Dental, £1,280.00 outstanding"
actions={
<>
<Button variant="ghost" size="icon" aria-label="Download PDF">
<DownloadIcon />
</Button>
<Button>Send reminder</Button>
</>
}
/>
<ScreenBody>
<div className="flex items-start gap-4">
<dl className="flex min-w-42 shrink-0 flex-col gap-2 rounded-xl bg-muted p-3">
{facts.map(({ label, value }) => (
<div key={label} className="flex justify-between gap-4">
<dt className="text-muted-foreground">{label}</dt>
<dd>{value}</dd>
</div>
))}
</dl>
<Tabs defaultValue="items" className="min-w-0 flex-1 gap-4">
<TabsList variant="line" aria-label="Sections of INV-2051" className="-ml-3.5">
<TabsTrigger value="items">Items</TabsTrigger>
<TabsTrigger value="payments">Payments</TabsTrigger>
<TabsTrigger value="activity">Activity</TabsTrigger>
</TabsList>
<TabsContent value="items" className={panel}>
<ItemGroup role="list" aria-label="Items of INV-2051" className="gap-2.5">
{lines.map(({ item, quantity, amount }) => (
<div key={item} role="listitem" className="flex flex-col gap-2.5">
<Item className="flex-nowrap items-start p-0 text-base">
<ItemContent className="min-w-0">
<ItemTitle className="line-clamp-none text-base">{item}</ItemTitle>
<ItemDescription className="text-base">{quantity}</ItemDescription>
</ItemContent>
<ItemActions className="shrink-0 tabular-nums">{amount}</ItemActions>
</Item>
<ItemSeparator className="my-0" />
</div>
))}
</ItemGroup>
<p className="flex justify-between gap-2 pt-2.5 font-medium">
<span>Total</span>
<span className="tabular-nums">£1,280.00</span>
</p>
</TabsContent>
<TabsContent value="payments" className={panel}>
<Empty className="gap-3 px-0 py-4">
<EmptyHeader>
<EmptyTitle className="text-base tracking-normal">No payments yet</EmptyTitle>
<EmptyDescription className="text-base">
Each payment you record is listed here with its date and amount.
</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button variant="outline">Record payment</Button>
</EmptyContent>
</Empty>
</TabsContent>
<TabsContent value="activity" className={panel}>
<ul className="flex flex-col gap-2">
{activity.map(({ event, date }) => (
<li key={event} className="flex justify-between gap-2">
<span>{event}</span>
<span className="shrink-0 text-muted-foreground">{date}</span>
</li>
))}
</ul>
</TabsContent>
</Tabs>
</div>
</ScreenBody>
</Screen>
)
}
A record opens with a breadcrumb trail back, then its identity: a mark, the name and one tag. Its facts follow as label and value rows in a narrower panel of at most seven, then its sections as tabs.
A home
Home
3 invoices awaiting payment
Paid in June £3,100, July £2,300, August £3,450, September £3,900, October £3,200 and November £915.
Recent payments
| Received | Customer | Amount |
|---|---|---|
| 18 Nov | Pennant Cycles | £915.00 |
| 30 Oct | Brightwater Dental | £540.00 |
| 24 Oct | Kestrel Print Co | £1,150.00 |
| 17 Oct | Oakline Joinery | £760.00 |
| 9 Oct | Brightwater Dental | £430.00 |
| 2 Oct | Kestrel Print Co | £320.00 |
"use client"
import { useState } from "react"
import { Bar, BarChart, XAxis } from "recharts"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@/components/ui/chart"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar, ScreenToolbar } from "~/components/principles/screen"
const ranges = [
{
value: "november",
label: "This month",
metrics: [
{ label: "Invoiced", figure: "£3,955", reading: "3 invoices" },
{ label: "Paid", figure: "£915", reading: "1 payment" },
],
},
{
value: "october",
label: "Last month",
metrics: [
{ label: "Invoiced", figure: "£4,480", reading: "4 invoices" },
{ label: "Paid", figure: "£3,200", reading: "5 payments" },
],
},
]
const today = [
{ label: "Outstanding", figure: "£4,320", reading: "3 invoices" },
{ label: "Overdue", figure: "£1,280", reading: "1 invoice" },
]
const months = [
{ month: "Jun", paid: 3100 },
{ month: "Jul", paid: 2300 },
{ month: "Aug", paid: 3450 },
{ month: "Sep", paid: 3900 },
{ month: "Oct", paid: 3200 },
{ month: "Nov", paid: 915 },
]
const config = {
paid: { label: "Paid, in pounds", color: "var(--chart-3)" },
} satisfies ChartConfig
const payments = [
{ received: "18 Nov", customer: "Pennant Cycles", amount: "£915.00" },
{ received: "30 Oct", customer: "Brightwater Dental", amount: "£540.00" },
{ received: "24 Oct", customer: "Kestrel Print Co", amount: "£1,150.00" },
{ received: "17 Oct", customer: "Oakline Joinery", amount: "£760.00" },
{ received: "9 Oct", customer: "Brightwater Dental", amount: "£430.00" },
{ received: "2 Oct", customer: "Kestrel Print Co", amount: "£320.00" },
]
export default function AHome() {
const [range, setRange] = useState("november")
const chosen = ranges.find(({ value }) => value === range) ?? ranges[0]
const metrics = [...chosen.metrics, ...today]
return (
<Screen sidebar={<ScreenSidebar current="Home" />}>
<ScreenHeader title="Home" line="3 invoices awaiting payment" />
<ScreenToolbar>
<Select items={ranges} value={range} onValueChange={(next) => setRange(next ?? "november")}>
<SelectTrigger aria-label="Range">
<SelectValue />
</SelectTrigger>
<SelectContent>
{ranges.map(({ value, label }) => (
<SelectItem key={value} value={value}>
{label}
</SelectItem>
))}
</SelectContent>
</Select>
</ScreenToolbar>
<ScreenBody>
<div className="grid grid-cols-4 gap-2">
{metrics.map(({ label, figure, reading }) => (
<Card key={label} size="sm">
<CardHeader>
<CardDescription>{label}</CardDescription>
<CardTitle className="text-xl">{figure}</CardTitle>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">{reading}</CardContent>
</Card>
))}
</div>
<Card size="sm">
<CardHeader>
<CardTitle className="text-base">Paid each month</CardTitle>
</CardHeader>
<CardContent>
<ChartContainer config={config} className="aspect-auto h-28 w-full">
<BarChart accessibilityLayer data={months} title="Amount paid each month, June to November">
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
<ChartTooltip content={<ChartTooltipContent />} />
<Bar dataKey="paid" fill="var(--color-paid)" barSize={20} isAnimationActive={false} />
</BarChart>
</ChartContainer>
<p className="sr-only">
Paid in June £3,100, July £2,300, August £3,450, September £3,900, October £3,200 and November £915.
</p>
</CardContent>
</Card>
<div className="flex flex-col gap-2">
<p className="font-medium">Recent payments</p>
<div className="-mx-3">
<Table aria-label="Recent payments">
<TableHeader>
<TableRow>
<TableHead>Received</TableHead>
<TableHead>Customer</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{payments.map((payment) => (
<TableRow key={payment.received}>
<TableCell>{payment.received}</TableCell>
<TableCell>{payment.customer}</TableCell>
<TableCell className="text-right">{payment.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
<a href="#a-list" className="self-start rounded-small text-link underline underline-offset-4 focus-ring">
View all 38 payments
</a>
</div>
</ScreenBody>
</Screen>
)
}
A home reads a range control, the metric row, a detail panel, then a list capped at six rows with a link to the full screen. Every metric carries a plain reading, and a home that commits nothing has no primary action.
A thread
Inbox
3 conversations
Brightwater Dental
About INV-2051
"use client"
import { InboxIcon } from "@keyline-icons/react"
import { useState } from "react"
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupTextarea } from "@/components/ui/input-group"
import { Message } from "@/components/ui/message"
import { SidebarMenu, SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar"
import { productNavigation, Screen, ScreenBody, ScreenHeader, ScreenSidebar } from "~/components/principles/screen"
const navigation = {
...productNavigation,
groups: [{ rows: [...productNavigation.groups.flatMap((group) => group.rows), { title: "Inbox", icon: InboxIcon }] }],
}
const conversations = [
{
customer: "Brightwater Dental",
about: "INV-2051",
messages: [
{ from: "customer", text: "Could you send INV-2051 again? It went to our old address." },
{ from: "studio", text: "Sent again, to accounts@brightwater.example." },
{ from: "customer", text: "Got it, thank you. We will pay it this week." },
],
},
{
customer: "Oakline Joinery",
about: "INV-2049",
messages: [{ from: "customer", text: "Can we pay INV-2049 in two parts?" }],
},
{
customer: "Kestrel Print Co",
about: "INV-2050",
messages: [
{ from: "studio", text: "INV-2050 is on its way. It is due on 28 November." },
{ from: "customer", text: "Received. It is with our accounts team." },
],
},
]
export default function AThread() {
const [threads, setThreads] = useState(conversations)
const [open, setOpen] = useState(0)
const [reply, setReply] = useState("")
const thread = threads[open]
return (
<Screen sidebar={<ScreenSidebar current="Inbox" navigation={navigation} />}>
<div className="flex flex-1">
<div className="flex w-44 shrink-0 flex-col border-r border-border">
<ScreenHeader title="Inbox" line="3 conversations" />
<div className="px-3 pt-4 pb-5">
<SidebarMenu aria-label="Conversations">
{threads.map(({ customer, messages }, index) => (
<SidebarMenuItem key={customer}>
<SidebarMenuButton
data-multiline
isActive={index === open}
aria-current={index === open ? "true" : undefined}
onClick={() => setOpen(index)}
>
<span className="flex min-w-0 flex-col">
<span className="truncate font-medium text-foreground">{customer}</span>
<span className="truncate">{messages.at(-1)?.text}</span>
</span>
</SidebarMenuButton>
</SidebarMenuItem>
))}
</SidebarMenu>
</div>
</div>
<div className="flex min-w-0 flex-1 flex-col">
<ScreenHeader title={thread.customer} line={`About ${thread.about}`} />
<ScreenBody>
{thread.messages.map(({ from, text }, index) =>
from === "studio" ? (
<Message key={index} from="user" aria-label="You wrote">
<p className="max-w-4/5 rounded-xl bg-muted px-3 py-2">{text}</p>
</Message>
) : (
<Message key={index} from="assistant" aria-label={`${thread.customer} wrote`}>
<p>{text}</p>
</Message>
),
)}
<form
className="mt-auto"
onSubmit={(event) => {
event.preventDefault()
const messages = [...thread.messages, { from: "studio", text: reply.trim() }]
setThreads(threads.map((item, index) => (index === open ? { ...item, messages } : item)))
setReply("")
}}
>
<InputGroup>
<InputGroupTextarea
aria-label={`Reply to ${thread.customer}`}
placeholder="Write a reply"
value={reply}
onChange={(event) => setReply(event.target.value)}
className="min-h-10 md:text-base"
/>
<InputGroupAddon align="block-end">
<InputGroupButton type="submit" size="sm" variant="default" className="ml-auto" disabled={!reply.trim()}>
Send reply
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</form>
</ScreenBody>
</div>
</div>
</Screen>
)
}
A thread is three panes: the navigation, the conversations and the thread. The composer at the thread's foot is the primary action, so its send button is the screen's one filled button.
Settings
Settings
Each change applies at once
import { useId } from "react"
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet } from "@/components/ui/field"
import { Switch } from "@/components/ui/switch"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar, ScreenToolbar } from "~/components/principles/screen"
const pages = [
{
value: "reminders",
label: "Reminders",
groups: [
{
title: "Schedule",
rows: [
{ name: "Before the due date", line: "Email the customer 3 days before an invoice is due.", on: true },
{ name: "After the due date", line: "Email again when an invoice is 7 days late.", on: true },
],
},
{
title: "Copies",
rows: [{ name: "A copy for me", line: "Send each reminder to accounts@harbour.example too.", on: false }],
},
],
},
{
value: "payments",
label: "Payments",
groups: [
{
title: "Ways to pay",
rows: [
{ name: "Card payments", line: "Customers pay by card from the invoice's link.", on: true },
{ name: "Bank transfers", line: "Show the studio's bank details on every invoice.", on: true },
],
},
{
title: "Instalments",
rows: [{ name: "Part payments", line: "Let a customer pay an invoice in instalments.", on: false }],
},
],
},
{
value: "numbering",
label: "Numbering",
groups: [
{
title: "Invoice numbers",
rows: [
{ name: "Prefix", line: "Number invoices INV-2051, INV-2052 and so on.", on: true },
{ name: "Restart each year", line: "The first invoice of a year takes the number 0001.", on: false },
],
},
],
},
{
value: "tax",
label: "Tax",
groups: [
{
title: "VAT",
rows: [
{ name: "Charge VAT", line: "Add 20% to every line of a new invoice.", on: false },
{ name: "Show the VAT number", line: "Print it in the footer of every invoice.", on: false },
],
},
],
},
{
value: "team",
label: "Team",
groups: [
{
title: "Members",
rows: [
{ name: "Send invoices", line: "A member sends an invoice without review.", on: true },
{ name: "Record payments", line: "A member marks an invoice as paid.", on: true },
],
},
],
},
]
export default function Settings() {
const id = useId()
return (
<Screen sidebar={<ScreenSidebar current="Settings" />}>
<ScreenHeader title="Settings" line="Each change applies at once" />
<Tabs defaultValue="reminders" className="min-w-0 flex-1 gap-0">
<ScreenToolbar>
<TabsList variant="line" aria-label="Settings" className="-ml-3.5">
{pages.map(({ value, label }) => (
<TabsTrigger key={value} value={value}>
{label}
</TabsTrigger>
))}
</TabsList>
</ScreenToolbar>
<ScreenBody>
{pages.map(({ value, groups }) => (
<TabsContent key={value} value={value} className="flex flex-col gap-6">
{groups.map(({ title, rows }, group) => (
<FieldSet key={title} className="max-w-sm">
<FieldLegend>{title}</FieldLegend>
<FieldGroup>
{rows.map(({ name, line, on }, row) => (
<Field key={name} orientation="horizontal">
<FieldContent>
<FieldLabel htmlFor={`${id}-${value}-${group}-${row}`}>{name}</FieldLabel>
<FieldDescription id={`${id}-${value}-${group}-${row}-line`}>{line}</FieldDescription>
</FieldContent>
<Switch
id={`${id}-${value}-${group}-${row}`}
defaultChecked={on}
aria-describedby={`${id}-${value}-${group}-${row}-line`}
/>
</Field>
))}
</FieldGroup>
</FieldSet>
))}
</TabsContent>
))}
</ScreenBody>
</Tabs>
</Screen>
)
}
Settings are a sub-navigation, then stacked groups of rows: a label, one line and its control at the right. Each row applies at once, so there is no Save and no primary action.
An overlay opens on its trigger
Oakline Joinery
£2,400.00 outstanding
- Contact
- Imogen Vale
- Terms
- 30 days
- Billed
- 2 invoices
- Since
- March 2024
Payments
"use client"
import { XIcon } from "@keyline-icons/react"
import { useId, useState } from "react"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb"
import { Button } from "@/components/ui/button"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from "@/components/ui/input-group"
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemSeparator, ItemTitle } from "@/components/ui/item"
import {
Popover,
PopoverContent,
PopoverDescription,
PopoverHeader,
PopoverTitle,
PopoverTrigger,
} from "@/components/ui/popover"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar } from "~/components/principles/screen"
const facts = [
{ label: "Contact", value: "Imogen Vale" },
{ label: "Terms", value: "30 days" },
{ label: "Billed", value: "2 invoices" },
{ label: "Since", value: "March 2024" },
]
const earlier = [{ invoice: "INV-2038", detail: "17 Oct, bank transfer", amount: "£760.00" }]
const methods = ["Bank transfer", "Card"]
const pounds = new Intl.NumberFormat("en-GB", { style: "currency", currency: "GBP" })
const day = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", timeZone: "UTC" })
export default function AnOverlayThatOpensOnItsTrigger() {
const id = useId()
const [open, setOpen] = useState(false)
const [outstanding, setOutstanding] = useState(2400)
const [payments, setPayments] = useState(earlier)
const [amount, setAmount] = useState("2,400.00")
const [method, setMethod] = useState(methods[0])
const [received, setReceived] = useState("2026-11-20")
const paid = Number(amount.replaceAll(",", ""))
return (
<Screen sidebar={<ScreenSidebar current="Customers" />}>
<ScreenHeader
trail={
<Breadcrumb aria-label="Path to Oakline Joinery">
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="#the-header">Customers</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>Oakline Joinery</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
}
mark={
<Avatar aria-hidden>
<AvatarFallback name="Oakline Joinery">OJ</AvatarFallback>
</Avatar>
}
title="Oakline Joinery"
line={`${pounds.format(outstanding)} outstanding`}
actions={
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger render={<Button />}>Record payment</PopoverTrigger>
<PopoverContent align="end" className="relative p-4">
<PopoverHeader>
<PopoverTitle>Record payment</PopoverTitle>
<PopoverDescription>Against INV-2049, due 12 December.</PopoverDescription>
</PopoverHeader>
<form
className="flex flex-col gap-4"
onSubmit={(event) => {
event.preventDefault()
const detail = `${day.format(new Date(received))}, ${method.toLowerCase()}`
setPayments([{ invoice: "INV-2049", detail, amount: pounds.format(paid) }, ...payments])
setOutstanding(outstanding - paid)
setAmount("")
setOpen(false)
}}
>
<FieldGroup className="gap-3">
<Field>
<FieldLabel htmlFor={`${id}-amount`}>Amount</FieldLabel>
<InputGroup>
<InputGroupAddon>
<InputGroupText>£</InputGroupText>
</InputGroupAddon>
<InputGroupInput
id={`${id}-amount`}
inputMode="decimal"
placeholder="0.00"
value={amount}
onChange={(event) => setAmount(event.target.value)}
/>
</InputGroup>
</Field>
<Field>
<FieldLabel htmlFor={`${id}-method`}>Method</FieldLabel>
<Select value={method} onValueChange={(next) => setMethod(next ?? methods[0])}>
<SelectTrigger id={`${id}-method`} className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
{methods.map((name) => (
<SelectItem key={name} value={name}>
{name}
</SelectItem>
))}
</SelectContent>
</Select>
</Field>
<Field>
<FieldLabel htmlFor={`${id}-received`}>Received</FieldLabel>
<Input
id={`${id}-received`}
type="date"
value={received}
onChange={(event) => setReceived(event.target.value)}
/>
</Field>
</FieldGroup>
<div className="flex justify-end gap-2">
<Button type="button" variant="outline" onClick={() => setOpen(false)}>
Cancel
</Button>
<Button type="submit" disabled={!(paid > 0 && paid <= outstanding) || !received}>
Record payment
</Button>
</div>
</form>
<Button
variant="ghost"
size="icon-sm"
aria-label="Close"
className="absolute top-3 right-3"
onClick={() => setOpen(false)}
>
<XIcon />
</Button>
</PopoverContent>
</Popover>
}
/>
<ScreenBody>
<div className="flex items-start gap-4">
<dl className="flex w-48 shrink-0 flex-col gap-2 rounded-xl bg-muted p-3">
{facts.map(({ label, value }) => (
<div key={label} className="flex justify-between gap-2">
<dt className="text-muted-foreground">{label}</dt>
<dd>{value}</dd>
</div>
))}
</dl>
<div className="flex min-w-0 flex-1 flex-col gap-1">
<p className="font-medium">Payments</p>
<ItemGroup role="list" aria-label="Payments from Oakline Joinery" className="gap-0">
{payments.map((payment, index) => (
<div key={payments.length - index} role="listitem">
{index > 0 ? <ItemSeparator className="my-0" /> : null}
<Item size="xs" className="px-0">
<ItemContent>
<ItemTitle>{payment.invoice}</ItemTitle>
<ItemDescription>{payment.detail}</ItemDescription>
</ItemContent>
<ItemActions>{payment.amount}</ItemActions>
</Item>
</div>
))}
</ItemGroup>
</div>
</div>
</ScreenBody>
</Screen>
)
}
A commit of up to four fields opens on its trigger as a popover: a title, close at the top right, and the commit as the right-most control with Cancel at its left. A centred dialog is kept for a confirmation, and for a commit with no trigger on screen.
The same job on a phone
Customers
5 customers
£1,280.00 outstanding
£640.00 outstanding
£2,400.00 outstanding
Nothing outstanding
Nothing outstanding
import { DownloadIcon, MenuIcon, MoreHorizontalIcon, SearchIcon, UploadIcon } from "@keyline-icons/react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemSeparator, ItemTitle } from "@/components/ui/item"
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
import { SidebarMenu, SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar"
import { productNavigation, Screen, ScreenBody, ScreenHeader } from "~/components/principles/screen"
const destinations = [...productNavigation.groups.flatMap((group) => group.rows), ...(productNavigation.foot ?? [])]
const customers = [
{ name: "Brightwater Dental", owes: "£1,280.00 outstanding", tags: ["Care plan", "14 days", "Purchase order"] },
{ name: "Kestrel Print Co", owes: "£640.00 outstanding", tags: ["Project", "14 days"] },
{ name: "Oakline Joinery", owes: "£2,400.00 outstanding", tags: ["Project", "30 days", "Purchase order", "Card on file"] },
{ name: "Pennant Cycles", owes: "Nothing outstanding", tags: ["Care plan", "14 days"] },
{ name: "Fernhill Bakery", owes: "Nothing outstanding", tags: ["Project"] },
]
export default function TheSameJobOnAPhone() {
return (
<Screen phone>
<ScreenHeader
mark={
<Sheet>
<SheetTrigger render={<Button variant="ghost" size="icon" aria-label="Open navigation" />}>
<MenuIcon />
</SheetTrigger>
<SheetContent side="left">
<SheetHeader>
<SheetTitle>{productNavigation.name}</SheetTitle>
</SheetHeader>
<SidebarMenu className="px-4">
{destinations.map(({ title, icon: Icon }) => (
<SidebarMenuItem key={title}>
<SidebarMenuButton
render={<span />}
isActive={title === "Customers"}
aria-current={title === "Customers" ? "true" : undefined}
className="pointer-events-none"
>
{Icon ? <Icon /> : null}
<span>{title}</span>
</SidebarMenuButton>
</SidebarMenuItem>
))}
</SidebarMenu>
</SheetContent>
</Sheet>
}
title="Customers"
line="5 customers"
actions={
<DropdownMenu>
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="More actions" />}>
<MoreHorizontalIcon />
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-48">
<DropdownMenuItem>
<SearchIcon />
Search customers
</DropdownMenuItem>
<DropdownMenuItem>
<DownloadIcon />
Export customers
</DropdownMenuItem>
<DropdownMenuItem>
<UploadIcon />
Import customers
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
}
/>
<ScreenBody rows>
<ItemGroup role="list" aria-label="Customers" className="gap-0">
{customers.map(({ name, owes, tags }, index) => (
<div key={name} role="listitem">
{index > 0 ? <ItemSeparator className="my-0" /> : null}
<Item size="sm">
<ItemContent>
<ItemTitle>{name}</ItemTitle>
<ItemDescription>{owes}</ItemDescription>
</ItemContent>
<ItemActions>
{tags.slice(0, 2).map((tag) => (
<Badge key={tag} variant="secondary">
{tag}
</Badge>
))}
{tags.length > 2 ? (
<Badge variant="outline">
+{tags.length - 2}
<span className="sr-only"> more tags</span>
</Badge>
) : null}
</ItemActions>
</Item>
</div>
))}
</ItemGroup>
</ScreenBody>
<div className="px-5 pb-5">
<Button className="w-full">Add customer</Button>
</div>
</Screen>
)
}
On a phone the screen does the same job in the same order, and nothing is cut. The sidebar becomes a drawer, the header's actions fold behind one menu and the primary action goes full width at the foot.
Budgets
A Budget is a ceiling on what a product or one screen may hold, and the profile sets the number: daily-use for a product people work in for hours a day, new-product for everything else.
The screens above sit at these limits, not over them: two labelled and two icon-only header actions, four metric cards, six rows in the home's list, and two chips then a "+N" chip on a customer's row. Khaeli's product pipeline counts the Budgets on each built screen with a test, and a screen over one is restructured before it ships.
Once for the product:
| Budget | new-product | daily-use |
|---|---|---|
Top-level navigation items | 7 | 15, in groups of at most 7 |
For each screen:
| Budget | new-product | daily-use |
|---|---|---|
Filled (primary) buttons | 1 | 1 |
Metric cards in a row | 4 | 5 |
Table columns | 6 | 10 |
Chips in a row | 2, then a "+N" chip | 2, then a "+N" chip |
Rows in a home list | 6, then the link | 6, then the link |
Content regions | 5 | 9 |
Text sizes | 4, and a fifth for a metric figure | 4, and a fifth for a metric figure |
Saturated hues | 5 | 5 |
Header actions | 2 labelled and 2 icon-only | 2 labelled and 2 icon-only |
Tabs in a row | 5; 7 in a settings sub-navigation; 3 in a view switch | the same |