Top Pages

1 variant

A sortable top pages table for web analytics, with share bars, row sparklines, and a detail view for each page.

Pages table

A sortable top pages table with tinted share bars behind each path, numbers that roll between 7d and 30d, and row sparklines. Clicking a row opens its daily trend, top referrers, and entry and exit rates.

Top pages

Top pages by views
Details
/38,420
/pricing21,960
/docs/getting-started17,340
/blog/edge-caching-notes14,870
/changelog11,200
/docs/api/events9,840
/integrations8,310
/signup7,650

1,284 pages · 412.3k views · avg 1m 42s

1–8 of 20
"use client";

import { TopPages } from "@/components/premium/top-pages";

export function TopPagesTablePreview() {
  return (
    <div className="w-full px-4 py-10">
      <TopPages />
    </div>
  );
}

Install

$ bunx --bun shadcn add @beui-pro/top-pages-table

API Reference

Every prop is optional unless marked required. Data, copy, and colors default to the sample content.

TopPages15 props
  • pages

    Pages with their numbers for every period.

    TopPage[]

    Default build()

  • periods

    Periods for the tabs; ids key each page's `stats` and `totals`.

    TopPagesPeriod[]
  • period

    Controlled period id.

    string
  • defaultPeriod

    Period id when uncontrolled; defaults to the first period.

    string
  • onPeriodChange

    Called when a period tab is chosen.

    ((period: string) => void)
  • totals

    Site totals per period id for the footer line.

    Record<string, TopPagesTotals>
  • endDate

    ISO date of each period's last day, for the trend readout.

    string

    Default 2026-11-28

  • defaultSort

    Starting sort.

    TopPagesSort
  • pageSize

    Rows per table page.

    number

    Default 8

  • colors

    Bar, chart and accent color classes; anything left out keeps its default.

    Partial<TopPagesColors>
  • bounceBands

    Bounce rate bands for the good, fair and bad colors.

    TopPagesBounceBands
  • toneClassNames

    Text color per bounce band; anything left out keeps its default.

    Partial<TopPagesToneClassNames>
  • formatters

    Formatter overrides; anything left out uses the defaults.

    Partial<TopPagesFormatters>
  • labels

    Copy overrides; anything left out uses the English defaults.

    Partial<TopPagesLabels>
  • className

    Classes merged onto the root element.

    string
PageDetail8 props
  • statsRequired

    Numbers for the expanded page in the selected period.

    TopPageStats
  • endDateRequired

    ISO date of the period's last day.

    string
  • labelsRequired

    Copy for headings and captions.

    TopPagesLabels
  • formattersRequired

    Number, duration and rate formatters.

    TopPagesFormatters
  • colorsRequired

    Chart and bar colors.

    PageDetailColors
  • bounceBandsRequired

    Bounce rate bands for the narrow-width stats.

    TopPagesBounceBands
  • toneClassNamesRequired

    Text color per bounce band.

    TopPagesToneClassNames
  • reduceRequired

    Skip movement, keep fades.

    boolean
PageRow16 props
  • pageRequired

    The page.

    TopPage
  • statsRequired

    Its numbers for the selected period.

    TopPageStats
  • periodRequired

    Selected period id; the sparkline redraws when it changes.

    string
  • shareRequired

    Share bar width, views over the period's top page, 0 to 1.

    number
  • expandedRequired

    Whether the detail below is open.

    boolean
  • onToggleRequired

    Called to open or close the detail.

    () => void
  • detailIdRequired

    Id of the detail row, for `aria-controls`.

    string
  • delayRequired

    Entrance delay in seconds; 0 for rows that arrive later.

    number
  • labelsRequired

    Copy for the expand button.

    TopPagesLabels
  • formattersRequired

    Number, duration and rate formatters.

    TopPagesFormatters
  • barClassNameRequired

    Share bar class, such as `bg-sky-500/15`.

    string
  • sparklineClassNameRequired

    Sparkline stroke class, such as `stroke-sky-500`.

    string
  • bounceBandsRequired

    Bounce rate bands.

    TopPagesBounceBands
  • toneClassNamesRequired

    Text color per bounce band.

    TopPagesToneClassNames
  • reduceRequired

    Skip movement, keep fades.

    boolean
  • ref

    The row element, so AnimatePresence can pop exiting rows out of the flow.

    Ref<HTMLTableRowElement>
PageTrend9 props
  • valuesRequired

    Views per day, oldest first.

    number[]
  • endDateRequired

    ISO date of the last value.

    string
  • titleRequired

    Heading above the chart, such as "Daily views".

    string
  • unitRequired

    Unit after the readout number, such as "views".

    string
  • formattersRequired

    Count and day formatters for the readout.

    Pick<TopPagesFormatters, "count" | "day">
  • strokeClassNameRequired

    Line color class, such as `stroke-sky-500`.

    string
  • fillClassNameRequired

    Area color class, such as `fill-sky-500/15`.

    string
  • dotClassNameRequired

    Dot color class for the hovered day, such as `bg-sky-500`.

    string
  • reduceRequired

    Skip the wipe and movement.

    boolean
SortHeader7 props
  • columnRequired

    Column this header sorts.

    "path" | "views" | "visitors" | "avgSeconds" | "bounceRate"
  • labelRequired

    Header text.

    string
  • sortRequired

    Current sort.

    TopPagesSort
  • onSortRequired

    Called with the column when the header is pressed.

    (key: TopPagesSortKey) => void
  • numeric

    Right-align the label, for number columns.

    boolean

    Default false

  • reduceRequired

    Skip the chevron turn.

    boolean
  • className

    Width and visibility classes for the cell.

    string
TopPagesEmpty4 props
  • titleRequired

    Title under the illustration.

    string
  • hintRequired

    Hint under the title.

    string
  • accentClassName

    Accent class for the lens, such as `text-sky-500`.

    string

    Default text-sky-500

  • reduceRequired

    Skip movement, keep fades.

    boolean
TopPagesFooter9 props
  • totals

    Site totals for the selected period, or undefined to hide the line.

    TopPagesTotals
  • fromRequired

    First row shown, 1-based; 0 when nothing matches.

    number
  • toRequired

    Last row shown.

    number
  • totalRequired

    Rows after filtering.

    number
  • pageRequired

    Current page, 0-based.

    number
  • pageCountRequired

    Number of pages.

    number
  • onPageChangeRequired

    Called with the page to show.

    (page: number) => void
  • labelsRequired

    Copy for totals and pagination.

    TopPagesLabels
  • formattersRequired

    Number and duration formatters.

    TopPagesFormatters
TopPagesHeader6 props
  • queryRequired

    Search text.

    string
  • onQueryChangeRequired

    Called as the search text changes.

    (query: string) => void
  • periodsRequired

    Periods for the tabs.

    TopPagesPeriod[]
  • periodRequired

    Selected period id.

    string
  • onPeriodChangeRequired

    Called when a period tab is chosen.

    (period: string) => void
  • labelsRequired

    Copy for the title, search and tabs.

    TopPagesLabels
TopPagesTable16 props
  • rowsRequired

    Rows on the current page, already sorted.

    TopPagesViewRow[]
  • periodRequired

    Selected period id.

    string
  • endDateRequired

    ISO date of the period's last day.

    string
  • maxViewsRequired

    Largest view count in the period, for share bars.

    number
  • sortRequired

    Current sort.

    TopPagesSort
  • onSortRequired

    Called when a header is pressed.

    (key: TopPagesSortKey) => void
  • expandedIdRequired

    Id of the expanded page, or null.

    string | null
  • onExpandedChangeRequired

    Called to open (id) or close (null) a row's detail.

    (id: string | null) => void
  • cascadeRequired

    Stagger rows in; true only for the first rows after mount.

    boolean
  • labelsRequired

    Copy for headings and buttons.

    TopPagesLabels
  • formattersRequired

    Number, duration and rate formatters.

    TopPagesFormatters
  • colorsRequired

    Bar, chart and sparkline colors.

    PageDetailColors & { sparkline: string; }
  • bounceBandsRequired

    Bounce rate bands.

    TopPagesBounceBands
  • toneClassNamesRequired

    Text color per bounce band.

    TopPagesToneClassNames
  • emptyRequired

    Shown in place of rows when nothing matches.

    ReactNode
  • reduceRequired

    Skip movement, keep fades.

    boolean
useTopPagesView6 props
  • pagesRequired

    Every page with its stats per period.

    TopPage[]
  • periodRequired

    Period whose stats are shown.

    string
  • queryRequired

    Search text that filters paths.

    string
  • sortRequired

    Column and direction to sort by.

    TopPagesSort
  • pageRequired

    Zero-based page of results.

    number
  • pageSizeRequired

    Rows per page.

    number
Types13 types

The object types these props take, field by field.

TopPagesColors6 fields
  • barRequired

    Share bar behind paths and referrers.

    string
  • sparklineRequired

    Row sparkline stroke.

    string
  • strokeRequired

    Detail trend line stroke.

    string
  • fillRequired

    Detail trend area fill.

    string
  • dotRequired

    Hovered-day dot on the trend.

    string
  • accentRequired

    Empty-state lens text color.

    string
TopPagesSort2 fields
  • keyRequired

    Column the rows are ordered by.

    TopPagesSortKey
  • directionRequired

    `desc` puts the largest value (or Z for paths) first.

    "asc" | "desc"
TopPagesPeriod2 fields
  • idRequired

    Stable id, used as the key into each page's `stats`.

    string
  • labelRequired

    Tab text, such as "7d".

    string
TopPage3 fields
  • idRequired

    Stable id.

    string
  • pathRequired

    URL path shown in mono, such as "/pricing".

    string
  • statsRequired

    Numbers keyed by period id. Pages missing a period are hidden in it.

    Record<string, TopPageStats>
TopPagesTotals3 fields
  • pagesRequired

    Pages with at least one view in the period.

    number
  • viewsRequired

    All page views in the period.

    number
  • avgSecondsRequired

    Average time on page across the site, in seconds.

    number
TopPagesLabels28 fields
  • titleRequired

    Card title.

    string
  • searchRequired

    Search field placeholder.

    string
  • searchLabelRequired

    Accessible name of the search field.

    string
  • periodsRequired

    Accessible name of the period tabs.

    string
  • pageRequired

    Page column heading.

    string
  • viewsRequired

    Views column heading.

    string
  • visitorsRequired

    Visitors column heading.

    string
  • avgTimeRequired

    Average time column heading.

    string
  • bounceRateRequired

    Bounce rate column heading.

    string
  • trendRequired

    Trend column heading.

    string
  • tableRequired

    Accessible name of the table.

    string
  • detailsRequired

    Screen-reader heading of the expand column.

    string
  • expandRequired

    Expand button label; receives the path.

    (path: string) => string
  • collapseRequired

    Collapse button label; receives the path.

    (path: string) => string
  • showRequired

    Expand button tooltip.

    string
  • hideRequired

    Collapse button tooltip.

    string
  • dailyViewsRequired

    Detail chart heading.

    string
  • referrersRequired

    Detail referrers heading.

    string
  • entryRateRequired

    Entry rate caption.

    string
  • exitRateRequired

    Exit rate caption.

    string
  • emptyTitleRequired

    Empty-search title.

    string
  • emptyHintRequired

    Empty-search hint; receives the query.

    (query: string) => string
  • pagesRequired

    Footer word after the page total.

    string
  • viewsTotalRequired

    Footer word after the view total.

    string
  • avgRequired

    Footer word before the average time.

    string
  • previousRequired

    Previous page button label.

    string
  • nextRequired

    Next page button label.

    string
  • rangeRequired

    Range text, such as "1–8 of 24".

    (from: number, to: number, total: number) => string
TopPagesFormatters5 fields
  • countRequired

    Full counts in cells and readouts, such as "21,960".

    (value: number) => string
  • compactRequired

    Short counts in the footer, such as "412k".

    (value: number) => string
  • durationRequired

    Seconds as a duration, such as "1m 42s".

    (seconds: number) => string
  • percentRequired

    A 0 to 100 rate, such as "38%".

    (value: number) => string
  • dayRequired

    A day in the trend readout, such as "Nov 24".

    (date: Date) => string
TopPagesBounceBands2 fields
  • goodRequired

    Highest rate still shown as good.

    number
  • badRequired

    Lowest rate shown as bad.

    number
TopPagesToneClassNames3 fields
  • goodRequired

    Rates at or under the good band.

    string
  • fairRequired

    Rates between the bands.

    string
  • badRequired

    Rates at or over the bad band.

    string
TopPageStats8 fields
  • viewsRequired

    Page views in the period.

    number
  • visitorsRequired

    Unique visitors in the period.

    number
  • avgSecondsRequired

    Average time on page, in seconds.

    number
  • bounceRateRequired

    Share of single-page sessions that started here, 0 to 100.

    number
  • entryRateRequired

    Share of sessions that started on this page, 0 to 100.

    number
  • exitRateRequired

    Share of sessions that ended on this page, 0 to 100.

    number
  • dailyRequired

    Views per day, oldest first; the last value is the period's end date.

    number[]
  • referrersRequired

    Top sources for this page, largest first. The detail shows the first three.

    TopPageReferrer[]
PageDetailColors4 fields
  • barRequired

    Share bar class behind referrer names, such as `bg-sky-500/15`.

    string
  • strokeRequired

    Trend line class, such as `stroke-sky-500`.

    string
  • fillRequired

    Trend area class, such as `fill-sky-500/15`.

    string
  • dotRequired

    Hovered-day dot class, such as `bg-sky-500`.

    string
TopPagesViewRow2 fields
  • pageRequired

    The page.

    TopPage
  • statsRequired

    Its numbers for the selected period.

    TopPageStats
TopPageReferrer2 fields
  • nameRequired

    Source name, such as "google.com" or "Direct".

    string
  • visitsRequired

    Visits from this source in the period.

    number