Named table views on a rail: when the filters drift, a ball hops onto the tab and opens into the list of what changed, each line with its own revert.
Change the valueChange the value
Tickets › Support queue
Saved views for Team Harbor
saved-views, lively
Use it above a table or list whose filters, sort and columns people save as named views: "All", "Mine", "Overdue" in a helpdesk queue, segments in a CRM, saved reports in analytics. It tells the person, without a word, that the table on screen no longer matches the view they saved, shows exactly what changed, and gives them Save and Reset right there. For a fixed set of filters that are never saved, use a segmented control; for navigation between pages, use tabs.
The motion follows the three beats. Pressing a tab charges: its label sinks and the pill's edge nudges toward it. Release and the pill stretches to the new tab, leading edge first, then contracts on it. When the live state drifts, the tab makes 14 px of room past its label and an 8 px ball hops onto it, landing with a small squash; Save and Reset rise next to the rail. Save throws the ball into the tab's trailing wall, where it squashes and fades; Reset throws it off its stop and pops it. The ball only ever moves away from the label, so it never covers a letter.
The ball opens into the diff. Hovering the unsaved tab swells the ball (the charge). Pressing the tab, or the "2 changes" button next to Save, grows the ball into a 240 px tile hanging from it: the 8 px shape keeps its corners while it widens, its primary fill fades in the first 40% of the growth and the lines rise after 60% of it. Each line says what moved against the saved view ("Priority: High removed", "Sort: Due date → Newest") and has its own revert, so the person can undo one field instead of all of them and knows what they are about to save over. Reverting the last line shrinks the tile back into the ball, which then pops off as Reset does. Save from the tile closes it first, then throws the ball. + grows into the name popover. calm glides the pill and the ball without hop or squash; nothing disappears.
pnpm dlx shadcn@latest add @motionkit-pro/saved-viewsnpx shadcn@latest add @motionkit-pro/saved-viewsyarn dlx shadcn@latest add @motionkit-pro/saved-viewsbunx --bun shadcn@latest add @motionkit-pro/saved-viewsRequires a Pro license and the @motionkit-pro registry with your token. See Installation.
import { SavedViews, type SavedView } from "@/components/ui/saved-views"
type Filters = { status?: string; priority?: string }
const initial: SavedView<Filters>[] = [
{ id: "all", label: "All", state: {}, locked: true, isDefault: true },
{ id: "mine", label: "Mine", state: { status: "Open" } },
{ id: "overdue", label: "Overdue", state: { status: "Open", priority: "High" } },
]
export function TicketViews() {
const [views, setViews] = useState(initial)
const [view, setView] = useState("overdue")
const [filters, setFilters] = useState<Filters>(initial[2].state)
return (
<SavedViews
views={views}
value={view}
current={filters}
onValueChange={(id) => {
setView(id)
setFilters(views.find((v) => v.id === id)!.state)
}}
onSave={(id, state) => setViews((all) => all.map((v) => (v.id === id ? { ...v, state } : v)))}
onSaveAs={(label, state) => {
const id = crypto.randomUUID()
setViews((all) => [...all, { id, label, state }])
return id
}}
onReset={(id) => setFilters(views.find((v) => v.id === id)!.state)}
/>
)
}current is your table's live state; the view is unsaved when isEqual(current, view.state) is false. The default compares stable JSON (sorted keys, undefined dropped), so a re-created object never makes the ball flicker. onSave and onSaveAs may return a promise: the Save button is aria-busy and the ball breathes on the trailing wall until it settles; a rejection sends the ball back to its stop and shows the message under the rail.
The changes tile lists describeChanges(current, saved): by default describeViewChanges, a shallow diff of plain objects (one line per key that differs, "columnFilters" labelled "Column filters", values through String, arrays joined). Pass your own to speak the product's words; each line is { key, label, from?, to? }, and a missing from or to reads as "added" or "removed". With onRevertField(id, key) every line gets a revert button; put that one field of the saved view back into your state.
<SavedViews
{...props}
describeChanges={(current, saved) => [
...(current.sort !== saved.sort
? [{ key: "sort", label: "Sort", from: SORTS[saved.sort], to: SORTS[current.sort] }]
: []),
]}
onRevertField={(id, key) => setFilters((f) => ({ ...f, [key]: viewById(id).state[key] }))}
/>With TanStack Table, useSavedViews({ table }) returns current (filters, sorting, visibility, order, pinning) and apply(state) to write a view back, so a filter bar, a column manager and the table share one state.
Behaviour change (November 2026): the view menu no longer offers "Duplicate" (save the live state with + instead), and pressing the active tab while it is unsaved now opens the changes tile instead of doing nothing. No prop was removed.
Pick a layout with preset: rail (tabs on a sunken rail, the default), select (one "View: Overdue" trigger that becomes the list, for narrow toolbars) or sidebar (a vertical list with counts, for a list-detail left column). Below collapseBelow (480 px of container width) the rail becomes the select trigger by itself (never narrower than 120 px: Save and Reset wrap under it); between that and its full width the rail scrolls inside its own track. maxVisible moves the rest under "More". Set the motion character with temperament or MotionKitProvider.
Prop
Type
Also accepts all props of Omit<
ComponentProps<"div">,
"defaultValue" | "onChange" | "onReset" | "children"
>.
The preview above: a "Tickets › Support queue" toolbar with three views, filter chips and a sort control. "Overdue" is already unsaved (its Priority chip removed, sorted by newest), and on first view the ball opens into the two changes and closes again. Revert a line, or press Save. "Work offline" makes the next save fail, to show the error under the rail.
A narrow "Orders" header: one trigger carries the view's name and the unsaved ball, and grows into the list of views.
Change the valueChange the value
Orders
saved-views, lively
The left column of an analytics screen: saved reports with counts, the pill travels down. Change the period to see the report marked as unsaved.
Change the valueChange the value
Churn by plan
Change the period: the saved report shows it has unsaved changes.
saved-views, lively
role="tablist" named by label ("Views"), each view a role="tab" with aria-selected; one tab stop, automatic activation. The sidebar preset sets aria-orientation="vertical".aria-hidden; the unsaved state is in the tab's name ("Overdue (unsaved changes)") and announced in a polite live region, with "Saved", "View reset" and the result of a rename or a new view.role="alert" line in destructive.aria-haspopup="dialog" and aria-expanded; the tile is a non-modal Radix popover named "2 changes to Overdue". Opened from the keyboard, focus moves to the first line's revert ("Revert Priority") and returns to the opener on Escape (to the tab when the opener has gone); opened with a pointer, focus stays where it was. Each revert is announced ("Priority reverted"). The old value is struck through and the arrow reads "to".sm), every icon button at least 24 px. Labels are foreground or muted-foreground, never a blend, in light and dark.| Key | Action |
|---|---|
Tab / Shift + Tab | Enters the rail on the active tab, then Options, +, Save, Reset |
ArrowLeft / ArrowRight | Activates the previous / next view (ArrowUp / ArrowDown in sidebar) |
Home / End | Activates the first / last view |
F2 | Renames the focused view (not on locked views) |
Shift + F10 / ContextMenu | Opens the view's menu: Rename, Set as default, Delete |
Enter / Space | On + opens the name popover; in the popover Enter saves |
Enter / Space | On the unsaved tab or "2 changes", opens the changes tile |
Escape | Closes the popover, the menu or the changes tile |
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") nothing hops, stretches or squashes. The pill glides with both edges together, the ball fades in on its stop and fades out on Save or Reset, Save and Reset fade in place, and the changes tile, the popover and the select list crossfade (the tile's lines appear together), all in the 120 ms fade. The unsaved state is as visible as with motion.
transform and opacity); React does not re-render while they move. The 14 px room opens at once and the tabs after it slide over on a transform (the reflow spring); the select trigger reserves the ball's stop, so it never changes width.ResizeObserver on the rail, so the pill follows the room as it opens.clip-path and a transform, its depth a drop-shadow that follows the clip; the diff is computed only while the view is unsaved.motion, @radix-ui/react-popover and @radix-ui/react-dropdown-menu (shared with the popover and dropdown menu items).Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-dropdown-menu, @radix-ui/react-popover, motion.
a value change, click, press
No hop, throw, squash or growth: the pill glides with both edges together, the ball fades on its stop, Save and Reset fade in place, the changes tile and the popover crossfade with their lines together, in the 120ms fade.
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)