Top Pages Table

Pages by visitors with share-of-traffic bars and a signed week-over-week change.

PROGet Top Pages Table and 168 other Pro components with pro lifetime — Get Pro

Category
Data Tables
Access
Pro
Source
176 lines · one file
States
6 drawn
Kind
Block

The decision inside it

Noise is not news

Changes under half a percent read 0% in the quiet tone, and a new page says New instead of an infinite percent, so the column only shouts when something moved.

When to use it

Use Top Pages Table in analytics for the most visited paths: visitors, share of traffic as a bar, and the signed change against the previous period. Pass previous counts; a page with none reads New.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Top Pages Table for this.
Install it: npx shadcn@latest add @liro/top-pages-table
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/top-pages-table.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/top-pages.tsx
import { TopPagesTable, type PageStat } from "@/components/ui/top-pages-table";

export function TopPages({ rows }: { rows: PageStat[] }) {
  return <TopPagesTable rows={rows} compareLabel="vs last week" onRowClick={(p) => console.info("open", p.path)} />;
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
rowsPageStat[] Yes–
compareLabelstring NoShown over the change column: "vs last week". Default "vs last week".
loadingboolean No–
errorReact.ReactNode No–
onRetry() => void No–
onRowClick(row: PageStat) => void No–
density"comfortable" | "compact" No–
variant"default" | "striped" | "bordered" No–
pageSizenumber NoRows per page. Default 10; 0 shows all.
classNamestring No–

Dependencies

npm packages

clsxlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themedata-table

States

All of them are drawn by the component. None is left for you to design.

  • By visitors
  • Rising and falling
  • New page
  • Loading
  • Empty
  • Error

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances