When things move
Whether each kind of interaction animates, as one table and eight things to try.
Whether each kind of interaction animates is decided once, before any screen is built, and the table below is the default. A product changes a verdict only with its reason written beside it, and the finish review holds each built screen to the table. Every duration, ease and spring is a foundation token, each one played on Motion, so no screen sets one.
The default for each kind of interaction
| Interaction | Verdict |
|---|---|
Opened or moved by a key (a shortcut, the command palette, arrow keys, a focus jump) | none |
Moving between screens; switching a tab or a segmented control | none |
Rows arriving, a chart drawing, a figure counting up when a screen loads | none |
Hovering a row or a list item | reduced |
Items inside a menu, a dropdown or a tab panel | none |
Pressing a button | standard |
A tooltip: the first in a group, then the next | standard, then none |
A figure changing because the person acted | standard |
A loading or running indicator (a spinner, a progress bar), while the wait lasts | standard |
The primary action opening its dialog, sheet or composer | standard |
A dropdown, select, filter menu or quick-look panel opening | standard |
A dialog, sheet or toast on an occasional screen (settings, billing, members) | standard |
An empty state, a setup step done, first run, success after a rare job | standard |
Dragging | none |
none is instant, reduced is a colour or opacity change only, standard is the foundation's motion for that component, and delight is a longer or richer moment, once.
A tab swaps its content at once
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 { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
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
const views = [
{ value: "all", label: "All", statuses: ["Overdue", "Sent", "Paid", "Draft"] },
{ value: "open", label: "Open", statuses: ["Overdue", "Sent"] },
{ value: "paid", label: "Paid", statuses: ["Paid"] },
]
export default function ATabSwapsItsContentAtOnce() {
return (
<Screen sidebar={<ScreenSidebar current="Invoices" />}>
<ScreenHeader title="Invoices" line="5 invoices, £4,320.00 outstanding" actions={<Button>Create invoice</Button>} />
<Tabs defaultValue="all" className="min-w-0 flex-1 gap-0">
<ScreenToolbar>
<TabsList aria-label="Invoices shown">
{views.map((view) => (
<TabsTrigger key={view.value} value={view.value}>
{view.label}
</TabsTrigger>
))}
</TabsList>
</ScreenToolbar>
<ScreenBody rows>
{views.map((view) => (
<TabsContent key={view.value} value={view.value} className="min-h-62">
<Table aria-label={`${view.label} invoices`}>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Customer</TableHead>
<TableHead>Status</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices
.filter((invoice) => view.statuses.includes(invoice.status))
.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>
</TabsContent>
))}
</ScreenBody>
</Tabs>
</Screen>
)
}
Switching a tab replaces the content at once, as moving between screens does. The marker that glides between the tabs belongs to the tabs component and stays as it ships.
A shortcut opens at once
You are on Invoices
"use client"
import { BanknoteIcon, HomeIcon, ReceiptIcon, SearchIcon, SettingsIcon, UsersIcon } from "@keyline-icons/react"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command"
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog"
import { Kbd } from "@/components/ui/kbd"
import { matchesHotkey } from "@/lib/hotkey"
const hotkey = "G"
const screens = [
{ title: "Home", Icon: HomeIcon },
{ title: "Invoices", Icon: ReceiptIcon },
{ title: "Customers", Icon: UsersIcon },
{ title: "Payments", Icon: BanknoteIcon },
{ title: "Settings", Icon: SettingsIcon },
]
export default function AShortcutOpensAtOnce() {
const [open, setOpen] = useState(false)
const [current, setCurrent] = useState("Invoices")
return (
<>
{/* The key is heard here only: it works while focus is inside this block. */}
<div
className="flex flex-col items-center gap-3"
onKeyDown={(event) => {
if (matchesHotkey(event.nativeEvent, hotkey)) setOpen(true)
}}
>
<Button variant="outline" aria-keyshortcuts={hotkey} onClick={() => setOpen(true)}>
<SearchIcon data-icon="inline-start" />
Go to a screen
<Kbd aria-hidden="true">{hotkey}</Kbd>
</Button>
<p role="status" className="text-muted-foreground">
You are on {current}
</p>
</div>
<Dialog open={open} onOpenChange={setOpen}>
{/* `command-palette` is the foundation's name for a dialog that holds a command: it opens at once. */}
<DialogContent className="command-palette overflow-hidden p-0" showCloseButton={false}>
<DialogTitle className="sr-only">Go to a screen</DialogTitle>
<DialogDescription className="sr-only">Choose a screen of Harbour studio.</DialogDescription>
<Command label="Go to a screen">
<CommandInput placeholder="Go to a screen" />
<CommandList>
<CommandEmpty>No screen matches.</CommandEmpty>
<CommandGroup heading="Screens">
{screens.map(({ title, Icon }) => (
<CommandItem
key={title}
onSelect={() => {
setCurrent(title)
setOpen(false)
}}
>
<Icon />
{title}
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</DialogContent>
</Dialog>
</>
)
}
What a key opens never animates: the palette is there at once, and the arrow keys move through it at once. The key works once the specimen has focus: move to the button, then press G.
A hovered row changes colour
Customers
5 customers, £4,320.00 outstanding
| Customer | Latest invoice | Outstanding |
|---|---|---|
| Brightwater Dental | INV-2051 | £1,280.00 |
| Kestrel Print Co | INV-2050 | £640.00 |
| Oakline Joinery | INV-2049 | £2,400.00 |
| Pennant Cycles | INV-2048 | £0.00 |
| Fernhill Bakery | INV-2047 | £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", latest: "INV-2051", outstanding: "£1,280.00" },
{ name: "Kestrel Print Co", latest: "INV-2050", outstanding: "£640.00" },
{ name: "Oakline Joinery", latest: "INV-2049", outstanding: "£2,400.00" },
{ name: "Pennant Cycles", latest: "INV-2048", outstanding: "£0.00" },
{ name: "Fernhill Bakery", latest: "INV-2047", outstanding: "£0.00" },
]
export default function AHoveredRowChangesColour() {
return (
<Screen sidebar={<ScreenSidebar current="Customers" />}>
<ScreenHeader title="Customers" line="5 customers, £4,320.00 outstanding" actions={<Button>Add customer</Button>} />
<ScreenBody rows>
<Table aria-label="Customers">
<TableHeader>
<TableRow>
<TableHead>Customer</TableHead>
<TableHead>Latest invoice</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.latest}</TableCell>
<TableCell className="text-right">{customer.outstanding}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</ScreenBody>
</Screen>
)
}
Hovering a row changes its colour and nothing else. Hover styles exist only for a pointer that can hover, so a touch screen never keeps one.
A menu grows from its trigger
"use client"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
const menus = [
{ name: "Status", align: "start", options: ["All", "Open", "Paid"] },
{ name: "Sort", align: "end", options: ["Newest first", "Oldest first", "Largest amount"] },
] as const
export default function AMenuGrowsFromItsTrigger() {
const [chosen, setChosen] = useState<Record<string, string>>({ Status: "Open", Sort: "Newest first" })
return (
<div className="flex w-full max-w-md items-center justify-between gap-2">
{menus.map(({ name, align, options }) => (
<DropdownMenu key={name}>
<DropdownMenuTrigger render={<Button variant="outline" />}>
{name}: {chosen[name]}
</DropdownMenuTrigger>
<DropdownMenuContent align={align} className="w-44">
<DropdownMenuRadioGroup
aria-label={name}
value={chosen[name]}
onValueChange={(option) => setChosen({ ...chosen, [name]: option })}
>
{options.map((option) => (
<DropdownMenuRadioItem key={option} value={option}>
{option}
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
))}
</div>
)
}
A menu, a select or a popover grows from the control that opened it, with the motion its component ships with. Its rows arrive with it as one piece, never one after another.
A dialog opens as it ships
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export default function ADialogOpensAsItShips() {
return (
<Dialog>
<DialogTrigger render={<Button variant="outline" />}>Void invoice</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Void INV-2049</DialogTitle>
<DialogDescription>Oakline Joinery will no longer owe £2,400.00. This cannot be undone.</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose render={<Button variant="outline" />}>Cancel</DialogClose>
<DialogClose render={<Button variant="destructive" />}>Void invoice</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
A dialog and its scrim arrive together and leave faster than they came. The screen sets nothing: the motion is the dialog component's own.
A tooltip and its neighbour
import { DownloadIcon, LinkIcon, PrinterIcon } from "@keyline-icons/react"
import { Button } from "@/components/ui/button"
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
const actions = [
{ label: "Download the PDF", Icon: DownloadIcon },
{ label: "Print the invoice", Icon: PrinterIcon },
{ label: "Copy the payment link", Icon: LinkIcon },
]
export default function ATooltipAndItsNeighbour() {
return (
<TooltipProvider>
<div className="flex items-center gap-1">
{actions.map(({ label, Icon }) => (
<Tooltip key={label}>
<TooltipTrigger render={<Button variant="ghost" size="icon" aria-label={label} />}>
<Icon />
</TooltipTrigger>
<TooltipContent>{label}</TooltipContent>
</Tooltip>
))}
</div>
</TooltipProvider>
)
}
The first tooltip in a group arrives with the foundation's motion, and its neighbour is there at once. A tooltip reached with the keyboard shows at once too.
A button answers a press
import { MoreHorizontalIcon } from "@keyline-icons/react"
import { Button } from "@/components/ui/button"
export default function AButtonAnswersAPress() {
return (
<div className="flex flex-wrap items-center justify-center gap-2">
<Button variant="ghost" size="icon" aria-label="More actions for INV-2050">
<MoreHorizontalIcon />
</Button>
<Button variant="outline">Save draft</Button>
<Button>Send invoice</Button>
</div>
)
}
A pressed button answers with its colour, its shadow and a slight scale, all of them the foundation's. A screen adds nothing to a press.
An indicator runs only while work runs
12 payments imported this morning
"use client"
import { LandmarkIcon } from "@keyline-icons/react"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item"
import { Spinner } from "@/components/ui/spinner"
export default function AnIndicatorRunsOnlyWhileWorkRuns() {
const [importing, setImporting] = useState(false)
return (
<Item variant="outline" className="max-w-md">
<ItemMedia variant="icon">{importing ? <Spinner aria-hidden /> : <LandmarkIcon />}</ItemMedia>
<ItemContent>
<ItemTitle>Bank feed</ItemTitle>
<ItemDescription role="status">
{importing ? "Importing payments from the bank" : "12 payments imported this morning"}
</ItemDescription>
</ItemContent>
<ItemActions>
<Button variant="outline" onClick={() => setImporting(!importing)}>
{importing ? "Stop the import" : "Import payments"}
</Button>
</ItemActions>
</Item>
)
}
A loading or running indicator is the one loop a working screen may run, and it stops when the work does. A wait too short to read shows no spinner at all.
Reduced motion
When a person asks for reduced motion, movement and scale go and fades stay. The foundation does this for every component, so a screen that adds no motion of its own has nothing to do.