States and words
What a screen shows when it is empty, loading, wrong, selected or done, and the words it uses to say so.
A screen is more than its default view. Each state below has a small, fixed shape, and each is named in the screen's plan before it is built. The Finish Review checks them on the built screen.
Empty on first use
Invoices
| Invoice | Customer | Status | Amount |
|---|---|---|---|
No invoices yet Each invoice you create is listed here with its status and amount. | |||
import { Button } from "@/components/ui/button"
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty"
import { Table, TableBody, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar } from "~/components/principles/screen"
export default function EmptyOnFirstUse() {
return (
<Screen sidebar={<ScreenSidebar current="Invoices" />}>
<ScreenHeader title="Invoices" 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>
<tr>
<td colSpan={4}>
<Empty className="py-12 max-sm:max-w-80">
<EmptyHeader>
<EmptyTitle>No invoices yet</EmptyTitle>
<EmptyDescription>Each invoice you create is listed here with its status and amount.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button variant="outline">Create invoice</Button>
</EmptyContent>
</Empty>
</td>
</tr>
</TableBody>
</Table>
</ScreenBody>
</Screen>
)
}
An empty state is a title line, at most one sentence and at most one action, with no illustration, and the header and the table's head stay in place. On first use the action creates the first item, and it is outlined because the header already holds the screen's one filled button.
Empty after a filter
Invoices
5 invoices, £4,320.00 outstanding
| Invoice | Customer | Status | Amount |
|---|---|---|---|
No invoices match “Harlow” | |||
"use client"
import { SearchIcon } from "@keyline-icons/react"
import { useRef, useState } from "react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Empty, EmptyContent, EmptyHeader, EmptyTitle } from "@/components/ui/empty"
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar, ScreenToolbar } 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 EmptyAfterAFilter() {
const [query, setQuery] = useState("Harlow")
const search = useRef<HTMLInputElement>(null)
const shown = invoices.filter((invoice) => invoice.customer.toLowerCase().includes(query.trim().toLowerCase()))
function clear() {
setQuery("")
search.current?.focus()
}
return (
<Screen sidebar={<ScreenSidebar current="Invoices" />}>
<ScreenHeader title="Invoices" line="5 invoices, £4,320.00 outstanding" actions={<Button>Create invoice</Button>} />
<ScreenToolbar>
<InputGroup className="w-56">
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
<InputGroupInput
ref={search}
aria-label="Search invoices by customer"
placeholder="Search by customer"
value={query}
onChange={(event) => setQuery(event.target.value)}
/>
</InputGroup>
</ScreenToolbar>
<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>
{shown.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>
))}
{shown.length === 0 ? (
<tr>
<td colSpan={4}>
<Empty className="py-10 max-sm:max-w-80">
<EmptyHeader>
<EmptyTitle className="break-words">No invoices match “{query.trim()}”</EmptyTitle>
</EmptyHeader>
<EmptyContent>
<Button variant="outline" onClick={clear}>
Clear search
</Button>
</EmptyContent>
</Empty>
</td>
</tr>
) : null}
</TableBody>
</Table>
</ScreenBody>
</Screen>
)
}
When a person's own search or filter empties the list, the screen says so and offers to clear it. Where nothing on the screen can fill the list, the empty state has no action.
Loading that keeps its size
Invoices
Loading invoices…
| Invoice | Customer | Status | Amount |
|---|---|---|---|
"use client"
import { useEffect, useState } from "react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Skeleton } from "@/components/ui/skeleton"
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 LoadingThatKeepsItsSize() {
const [loading, setLoading] = useState(true)
const [refreshes, setRefreshes] = useState(0)
// The timer stands in for the product's request. The first load is held so it can be seen.
useEffect(() => {
if (refreshes === 0) return
setLoading(true)
const timer = setTimeout(() => setLoading(false), 1600)
return () => clearTimeout(timer)
}, [refreshes])
return (
<Screen sidebar={<ScreenSidebar current="Invoices" />}>
<ScreenHeader
title="Invoices"
line={loading ? "Loading invoices…" : "5 invoices, £4,320.00 outstanding"}
actions={
<>
<Button variant="outline" onClick={() => setRefreshes(refreshes + 1)}>
Refresh
</Button>
<Button>Create invoice</Button>
</>
}
/>
<ScreenBody rows>
<Table aria-label="Invoices" aria-busy={loading}>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Customer</TableHead>
<TableHead>Status</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) =>
loading ? (
<TableRow key={invoice.number}>
<TableCell>
<Skeleton className="h-3.5 w-16" />
</TableCell>
<TableCell>
<Skeleton className="h-3.5 w-28" />
</TableCell>
<TableCell>
<Skeleton className="h-3.5 w-12" />
</TableCell>
<TableCell>
<Skeleton className="ml-auto h-3.5 w-16" />
</TableCell>
</TableRow>
) : (
<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 loading region keeps its final size and says what is loading, so the content arrives without moving the page. Press Refresh to watch the rows replace their skeletons in place.
A running action on its button
Brightwater Dental owes £1,280.00
Kestrel Print Co owes £640.00
Oakline Joinery owes £2,400.00
"use client"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemTitle } from "@/components/ui/item"
import { Spinner } from "@/components/ui/spinner"
const unpaid = [
{ number: "INV-2051", owes: "Brightwater Dental owes £1,280.00" },
{ number: "INV-2050", owes: "Kestrel Print Co owes £640.00" },
{ number: "INV-2049", owes: "Oakline Joinery owes £2,400.00" },
]
export default function ARunningActionOnItsButton() {
const [reminders, setReminders] = useState<Record<string, "sending" | "sent">>({ "INV-2050": "sending" })
// The timer stands in for the product's request.
function send(number: string) {
setReminders((current) => ({ ...current, [number]: "sending" }))
setTimeout(() => setReminders((current) => ({ ...current, [number]: "sent" })), 2000)
}
return (
<ItemGroup className="max-w-md gap-2">
{unpaid.map(({ number, owes }) => (
<Item key={number} variant="outline">
<ItemContent>
<ItemTitle>{number}</ItemTitle>
<ItemDescription>{owes}</ItemDescription>
</ItemContent>
<ItemActions>
<Button variant="outline" disabled={number in reminders} onClick={() => send(number)}>
{reminders[number] === "sending" ? <Spinner data-icon="inline-start" aria-hidden /> : null}
{reminders[number] === "sending" ? "Sending…" : reminders[number] === "sent" ? "Sent" : "Send reminder"}
</Button>
</ItemActions>
</Item>
))}
</ItemGroup>
)
}
A running action names itself on its own button and disables it until it is done. The spinner turns only while the work lasts.
An error beside its field
"use client"
import { useId, useState } from "react"
import { Button } from "@/components/ui/button"
import { Field, FieldError, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
export default function AnErrorBesideItsField() {
const id = useId()
const [email, setEmail] = useState("accounts@brightwater")
const invalid = !/^\S+@\S+\.\S+$/.test(email)
return (
<FieldGroup className="max-w-xs">
<Field>
<FieldLabel htmlFor={`${id}-name`}>Customer</FieldLabel>
<Input id={`${id}-name`} defaultValue="Brightwater Dental" />
</Field>
<Field data-invalid={invalid}>
<FieldLabel htmlFor={`${id}-email`}>Send invoices to</FieldLabel>
<Input
id={`${id}-email`}
type="email"
value={email}
onChange={(event) => setEmail(event.target.value)}
aria-invalid={invalid}
aria-describedby={invalid ? `${id}-error` : undefined}
/>
{invalid ? (
<FieldError id={`${id}-error`}>
Invoices cannot reach this address. Enter it in full, such as accounts@brightwater.example.
</FieldError>
) : null}
</Field>
<Button disabled={invalid} className="self-end">
Save customer
</Button>
</FieldGroup>
)
}
An error says what happened and the next step, where it happened: beside the field, in the form, in the run. A local fault never becomes a full-page error.
Done, with Undo
Invoices
4 invoices
| Invoice | Customer | Amount | Actions |
|---|---|---|---|
| INV-2051 | Brightwater Dental | £1,280.00 | |
| INV-2050 | Kestrel Print Co | £640.00 | |
| INV-2049 | Oakline Joinery | £2,400.00 | |
| INV-2048 | Pennant Cycles | £915.00 |
"use client"
import { MoreHorizontalIcon } from "@keyline-icons/react"
import { useEffect, useRef, useState } from "react"
import { Button } from "@/components/ui/button"
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { Toaster } from "@/components/ui/sonner"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { useUndoBatch } from "@/hooks/use-undo-batch"
import { Screen, ScreenBody, ScreenHeader, ScreenSidebar } from "~/components/principles/screen"
const invoices = [
{ number: "INV-2051", customer: "Brightwater Dental", amount: "£1,280.00" },
{ number: "INV-2050", customer: "Kestrel Print Co", amount: "£640.00" },
{ number: "INV-2049", customer: "Oakline Joinery", amount: "£2,400.00" },
{ number: "INV-2048", customer: "Pennant Cycles", amount: "£915.00" },
{ number: "INV-2047", customer: "Fernhill Bakery", amount: "£350.00" },
]
const message = (count: number) => (count === 1 ? "1 invoice deleted" : `${count} invoices deleted`)
export default function DoneWithUndo() {
const [deleted, setDeleted] = useState(["INV-2047"])
const rows = invoices.filter((invoice) => !deleted.includes(invoice.number))
const restore = (number: string) => setDeleted((current) => current.filter((item) => item !== number))
const deletions = useUndoBatch({ id: "invoices-deleted", message })
// INV-2047 was deleted a moment ago: its toast stays until it is answered, so it can be seen.
const earlier = useUndoBatch({ id: "invoice-deleted-earlier", message, durationMs: Number.POSITIVE_INFINITY })
const shown = useRef(false)
useEffect(() => {
if (shown.current) return
shown.current = true
earlier.push({ undo: () => restore("INV-2047") })
}, [earlier])
function remove(number: string) {
setDeleted((current) => [...current, number])
deletions.push({ undo: () => restore(number) })
}
return (
<Screen sidebar={<ScreenSidebar current="Invoices" />}>
<ScreenHeader
title="Invoices"
line={rows.length === 1 ? "1 invoice" : `${rows.length} invoices`}
actions={<Button>Create invoice</Button>}
/>
<ScreenBody rows>
<div className="relative isolate flex-1 pb-16">
<Table aria-label="Invoices">
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Customer</TableHead>
<TableHead className="text-right">Amount</TableHead>
<TableHead>
<span className="sr-only">Actions</span>
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{rows.map((invoice) => (
<TableRow key={invoice.number}>
<TableCell className="font-medium">{invoice.number}</TableCell>
<TableCell>{invoice.customer}</TableCell>
<TableCell className="text-right">{invoice.amount}</TableCell>
<TableCell className="w-0">
<DropdownMenu>
<DropdownMenuTrigger
render={<Button variant="ghost" size="icon" aria-label={`Actions for ${invoice.number}`} />}
>
<MoreHorizontalIcon />
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem variant="destructive" onClick={() => remove(invoice.number)}>
Delete invoice
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
<div className="absolute bottom-0 left-0 h-16 w-full max-sm:max-w-85">
<Toaster position="bottom-right" offset={8} mobileOffset={8} className="absolute!" />
</div>
</div>
</ScreenBody>
</Screen>
)
}
An edit or a delete runs at once, and one neutral toast with at most one action offers Undo; quick deletes share that toast. A confirmation is kept for what cannot be undone.
Selection and its bulk bar
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 |
"use client"
import { useState } from "react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
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 SelectionAndItsBulkBar() {
const [selected, setSelected] = useState<string[]>(["INV-2051", "INV-2050"])
const count = selected.length
const all = count === invoices.length
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>
<Checkbox
aria-label="Select all invoices"
checked={all}
indeterminate={count > 0 && !all}
onCheckedChange={(next) => setSelected(next ? invoices.map((invoice) => invoice.number) : [])}
/>
</TableHead>
<TableHead>Invoice</TableHead>
<TableHead>Customer</TableHead>
<TableHead>Status</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => {
const checked = selected.includes(invoice.number)
return (
<TableRow key={invoice.number} data-state={checked ? "selected" : undefined}>
<TableCell>
<Checkbox
aria-label={`Select ${invoice.number}`}
checked={checked}
onCheckedChange={(next) =>
setSelected(next ? [...selected, invoice.number] : selected.filter((item) => item !== invoice.number))
}
/>
</TableCell>
<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>
<div className="mt-3 h-10.5 px-1" aria-live="polite">
{count > 0 ? (
<div className="flex items-center justify-between gap-2 rounded-tray bg-muted py-1.5 pr-1.5 pl-3">
<span>{count === 1 ? "1 invoice selected" : `${count} invoices selected`}</span>
<div className="flex items-center gap-2">
<Button variant="ghost" onClick={() => setSelected([])}>
Clear selection
</Button>
<Button variant="outline" onClick={() => setSelected([])}>
{count === 1 ? "Send 1 reminder" : `Send ${count} reminders`}
</Button>
</div>
</div>
) : null}
</div>
</ScreenBody>
</Screen>
)
}
A selected row takes a neutral fill. Bulk actions arrive in a bar once rows are selected, and the bar states the count.
Disabled
A sent invoice keeps its number.
import { useId } from "react"
import { Button } from "@/components/ui/button"
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
export default function Disabled() {
const id = useId()
return (
<div className="flex w-full max-w-xs flex-col gap-4">
<Field data-disabled="true">
<FieldLabel htmlFor={id}>Invoice number</FieldLabel>
<Input id={id} defaultValue="INV-2048" disabled aria-describedby={`${id}-reason`} />
<FieldDescription id={`${id}-reason`}>A sent invoice keeps its number.</FieldDescription>
</Field>
<div className="flex justify-end gap-2">
<DropdownMenu>
<DropdownMenuTrigger render={<Button variant="outline" />}>More actions</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-60">
<DropdownMenuItem>Duplicate invoice</DropdownMenuItem>
<DropdownMenuItem>Download PDF</DropdownMenuItem>
<DropdownMenuItem disabled>
Send reminder
<span className="ml-auto">Already paid</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<Button disabled>Record payment</Button>
</div>
</div>
)
}
A disabled control is the same control at reduced opacity. A disabled menu item says why: open More actions to read the reason.
A label starts with a verb
Brightwater Dental owes £1,280.00
import { Button } from "@/components/ui/button"
import { Item, ItemActions, ItemContent, ItemDescription, ItemTitle } from "@/components/ui/item"
export default function ALabelStartsWithAVerb() {
return (
<Item variant="outline" className="max-w-lg">
<ItemContent>
<ItemTitle>INV-2051</ItemTitle>
<ItemDescription>Brightwater Dental owes £1,280.00</ItemDescription>
</ItemContent>
<ItemActions>
<Button variant="outline">Send reminder</Button>
<Button>Record payment</Button>
</ItemActions>
</Item>
)
}
A button starts with a verb and names the outcome. Titles, buttons and labels are sentence case.
A label says its number
"use client"
import { useId, useState } from "react"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
const customers = ["Brightwater Dental", "Kestrel Print Co", "Oakline Joinery", "Pennant Cycles", "Fernhill Bakery"]
export default function ALabelSaysItsNumber() {
const id = useId()
const [chosen, setChosen] = useState(customers.slice(0, 3))
const count = chosen.length
return (
<div className="flex w-full max-w-xs flex-col gap-4">
<FieldGroup data-slot="checkbox-group">
{customers.map((customer, index) => (
<Field key={customer} orientation="horizontal">
<Checkbox
id={`${id}-${index}`}
checked={chosen.includes(customer)}
onCheckedChange={(next) => setChosen(next ? [...chosen, customer] : chosen.filter((item) => item !== customer))}
/>
<FieldLabel htmlFor={`${id}-${index}`}>{customer}</FieldLabel>
</Field>
))}
</FieldGroup>
<Button disabled={count === 0} className="self-end">
{count === 0 ? "Send statements" : count === 1 ? "Send 1 statement" : `Send ${count} statements`}
</Button>
</div>
)
}
Where the outcome has a number, the label says it. The number follows the selection, down to the singular.
A count with its noun
Customers
5 customers, 9 invoices
| Customer | Billed | Outstanding |
|---|---|---|
| Brightwater Dental | 3 invoices | £1,280.00 |
| Kestrel Print Co | 2 invoices | £640.00 |
| Oakline Joinery | 2 invoices | £2,400.00 |
| Pennant Cycles | 1 invoice | £0.00 |
| Fernhill Bakery | 1 invoice | £0.00 |
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 customers = [
{ name: "Brightwater Dental", invoices: "3 invoices", outstanding: "£1,280.00" },
{ name: "Kestrel Print Co", invoices: "2 invoices", outstanding: "£640.00" },
{ name: "Oakline Joinery", invoices: "2 invoices", outstanding: "£2,400.00" },
{ name: "Pennant Cycles", invoices: "1 invoice", outstanding: "£0.00" },
{ name: "Fernhill Bakery", invoices: "1 invoice", outstanding: "£0.00" },
]
export default function ACountWithItsNoun() {
return (
<Screen sidebar={<ScreenSidebar current="Customers" />}>
<ScreenHeader title="Customers" line="5 customers, 9 invoices" actions={<Button>Add customer</Button>} />
<ScreenBody rows>
<Table aria-label="Customers">
<TableHeader>
<TableRow>
<TableHead>Customer</TableHead>
<TableHead>Billed</TableHead>
<TableHead className="text-right">Outstanding</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{customers.map((customer) => (
<TableRow key={customer.name}>
<TableCell className="font-medium">{customer.name}</TableCell>
<TableCell>{customer.invoices}</TableCell>
<TableCell className="text-right">{customer.outstanding}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</ScreenBody>
</Screen>
)
}
A count carries its noun, in a cell as in the one line under the title. That line states a count, a scope or a status, and never restates the title.
Work in progress, and done
"use client"
import { CircleCheckIcon } from "@keyline-icons/react"
import { useEffect, useState } from "react"
import { Button } from "@/components/ui/button"
import { Item, ItemContent, ItemGroup, ItemMedia, ItemTitle } from "@/components/ui/item"
import { Spinner } from "@/components/ui/spinner"
const steps = [
{ running: "Importing 48 customers…", done: "Imported 48 customers" },
{ running: "Matching 9 invoices…", done: "Matched 9 invoices" },
]
export default function WorkInProgressAndDone() {
const [finished, setFinished] = useState(1)
const [runs, setRuns] = useState(0)
// The timers stand in for the product's work. The first run is held at its second step so both tenses can be seen.
useEffect(() => {
if (runs === 0) return
setFinished(0)
const timers = [setTimeout(() => setFinished(1), 1800), setTimeout(() => setFinished(2), 3600)]
return () => timers.forEach(clearTimeout)
}, [runs])
return (
<div className="flex w-full max-w-xs flex-col gap-4">
<ItemGroup role="status">
{steps.map((step, index) => (
<Item key={step.done} size="xs" className={index > finished ? "invisible" : undefined}>
<ItemMedia variant="icon">{index < finished ? <CircleCheckIcon /> : <Spinner aria-hidden />}</ItemMedia>
<ItemContent>
<ItemTitle className={index < finished ? "font-normal text-muted-foreground" : undefined}>
{index < finished ? step.done : step.running}
</ItemTitle>
</ItemContent>
</Item>
))}
</ItemGroup>
<Button variant="outline" className="self-end" onClick={() => setRuns(runs + 1)}>
Import again
</Button>
</div>
)
}
Work in progress is the verb in "-ing" with an ellipsis, and done is the past tense. Khaeli's product pipeline runs its copy rules over every label before the owner sees the screen.