Top Pages

1 个变体

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>
  );
}

安装

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

API 参考

除标注为必填的属性外,其余均为可选。数据、文案和颜色默认使用示例内容。

TopPages15 个属性
  • pages

    Pages with their numbers for every period.

    TopPage[]

    默认值 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

    默认值 2026-11-28

  • defaultSort

    Starting sort.

    TopPagesSort
  • pageSize

    Rows per table page.

    number

    默认值 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 个属性
  • stats必填

    Numbers for the expanded page in the selected period.

    TopPageStats
  • endDate必填

    ISO date of the period's last day.

    string
  • labels必填

    Copy for headings and captions.

    TopPagesLabels
  • formatters必填

    Number, duration and rate formatters.

    TopPagesFormatters
  • colors必填

    Chart and bar colors.

    PageDetailColors
  • bounceBands必填

    Bounce rate bands for the narrow-width stats.

    TopPagesBounceBands
  • toneClassNames必填

    Text color per bounce band.

    TopPagesToneClassNames
  • reduce必填

    Skip movement, keep fades.

    boolean
PageRow16 个属性
  • page必填

    The page.

    TopPage
  • stats必填

    Its numbers for the selected period.

    TopPageStats
  • period必填

    Selected period id; the sparkline redraws when it changes.

    string
  • share必填

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

    number
  • expanded必填

    Whether the detail below is open.

    boolean
  • onToggle必填

    Called to open or close the detail.

    () => void
  • detailId必填

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

    string
  • delay必填

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

    number
  • labels必填

    Copy for the expand button.

    TopPagesLabels
  • formatters必填

    Number, duration and rate formatters.

    TopPagesFormatters
  • barClassName必填

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

    string
  • sparklineClassName必填

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

    string
  • bounceBands必填

    Bounce rate bands.

    TopPagesBounceBands
  • toneClassNames必填

    Text color per bounce band.

    TopPagesToneClassNames
  • reduce必填

    Skip movement, keep fades.

    boolean
  • ref

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

    Ref<HTMLTableRowElement>
PageTrend9 个属性
  • values必填

    Views per day, oldest first.

    number[]
  • endDate必填

    ISO date of the last value.

    string
  • title必填

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

    string
  • unit必填

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

    string
  • formatters必填

    Count and day formatters for the readout.

    Pick<TopPagesFormatters, "count" | "day">
  • strokeClassName必填

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

    string
  • fillClassName必填

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

    string
  • dotClassName必填

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

    string
  • reduce必填

    Skip the wipe and movement.

    boolean
SortHeader7 个属性
  • column必填

    Column this header sorts.

    "path" | "views" | "visitors" | "avgSeconds" | "bounceRate"
  • label必填

    Header text.

    string
  • sort必填

    Current sort.

    TopPagesSort
  • onSort必填

    Called with the column when the header is pressed.

    (key: TopPagesSortKey) => void
  • numeric

    Right-align the label, for number columns.

    boolean

    默认值 false

  • reduce必填

    Skip the chevron turn.

    boolean
  • className

    Width and visibility classes for the cell.

    string
TopPagesEmpty4 个属性
  • title必填

    Title under the illustration.

    string
  • hint必填

    Hint under the title.

    string
  • accentClassName

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

    string

    默认值 text-sky-500

  • reduce必填

    Skip movement, keep fades.

    boolean
TopPagesFooter9 个属性
  • totals

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

    TopPagesTotals
  • from必填

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

    number
  • to必填

    Last row shown.

    number
  • total必填

    Rows after filtering.

    number
  • page必填

    Current page, 0-based.

    number
  • pageCount必填

    Number of pages.

    number
  • onPageChange必填

    Called with the page to show.

    (page: number) => void
  • labels必填

    Copy for totals and pagination.

    TopPagesLabels
  • formatters必填

    Number and duration formatters.

    TopPagesFormatters
TopPagesHeader6 个属性
  • query必填

    Search text.

    string
  • onQueryChange必填

    Called as the search text changes.

    (query: string) => void
  • periods必填

    Periods for the tabs.

    TopPagesPeriod[]
  • period必填

    Selected period id.

    string
  • onPeriodChange必填

    Called when a period tab is chosen.

    (period: string) => void
  • labels必填

    Copy for the title, search and tabs.

    TopPagesLabels
TopPagesTable16 个属性
  • rows必填

    Rows on the current page, already sorted.

    TopPagesViewRow[]
  • period必填

    Selected period id.

    string
  • endDate必填

    ISO date of the period's last day.

    string
  • maxViews必填

    Largest view count in the period, for share bars.

    number
  • sort必填

    Current sort.

    TopPagesSort
  • onSort必填

    Called when a header is pressed.

    (key: TopPagesSortKey) => void
  • expandedId必填

    Id of the expanded page, or null.

    string | null
  • onExpandedChange必填

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

    (id: string | null) => void
  • cascade必填

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

    boolean
  • labels必填

    Copy for headings and buttons.

    TopPagesLabels
  • formatters必填

    Number, duration and rate formatters.

    TopPagesFormatters
  • colors必填

    Bar, chart and sparkline colors.

    PageDetailColors & { sparkline: string; }
  • bounceBands必填

    Bounce rate bands.

    TopPagesBounceBands
  • toneClassNames必填

    Text color per bounce band.

    TopPagesToneClassNames
  • empty必填

    Shown in place of rows when nothing matches.

    ReactNode
  • reduce必填

    Skip movement, keep fades.

    boolean
useTopPagesView6 个属性
  • pages必填

    Every page with its stats per period.

    TopPage[]
  • period必填

    Period whose stats are shown.

    string
  • query必填

    Search text that filters paths.

    string
  • sort必填

    Column and direction to sort by.

    TopPagesSort
  • page必填

    Zero-based page of results.

    number
  • pageSize必填

    Rows per page.

    number
类型13 个类型

这些属性使用的对象类型及其字段。

TopPagesColors6 个字段
  • bar必填

    Share bar behind paths and referrers.

    string
  • sparkline必填

    Row sparkline stroke.

    string
  • stroke必填

    Detail trend line stroke.

    string
  • fill必填

    Detail trend area fill.

    string
  • dot必填

    Hovered-day dot on the trend.

    string
  • accent必填

    Empty-state lens text color.

    string
TopPagesSort2 个字段
  • key必填

    Column the rows are ordered by.

    TopPagesSortKey
  • direction必填

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

    "asc" | "desc"
TopPagesPeriod2 个字段
  • id必填

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

    string
  • label必填

    Tab text, such as "7d".

    string
TopPage3 个字段
  • id必填

    Stable id.

    string
  • path必填

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

    string
  • stats必填

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

    Record<string, TopPageStats>
TopPagesTotals3 个字段
  • pages必填

    Pages with at least one view in the period.

    number
  • views必填

    All page views in the period.

    number
  • avgSeconds必填

    Average time on page across the site, in seconds.

    number
TopPagesLabels28 个字段
  • title必填

    Card title.

    string
  • search必填

    Search field placeholder.

    string
  • searchLabel必填

    Accessible name of the search field.

    string
  • periods必填

    Accessible name of the period tabs.

    string
  • page必填

    Page column heading.

    string
  • views必填

    Views column heading.

    string
  • visitors必填

    Visitors column heading.

    string
  • avgTime必填

    Average time column heading.

    string
  • bounceRate必填

    Bounce rate column heading.

    string
  • trend必填

    Trend column heading.

    string
  • table必填

    Accessible name of the table.

    string
  • details必填

    Screen-reader heading of the expand column.

    string
  • expand必填

    Expand button label; receives the path.

    (path: string) => string
  • collapse必填

    Collapse button label; receives the path.

    (path: string) => string
  • show必填

    Expand button tooltip.

    string
  • hide必填

    Collapse button tooltip.

    string
  • dailyViews必填

    Detail chart heading.

    string
  • referrers必填

    Detail referrers heading.

    string
  • entryRate必填

    Entry rate caption.

    string
  • exitRate必填

    Exit rate caption.

    string
  • emptyTitle必填

    Empty-search title.

    string
  • emptyHint必填

    Empty-search hint; receives the query.

    (query: string) => string
  • pages必填

    Footer word after the page total.

    string
  • viewsTotal必填

    Footer word after the view total.

    string
  • avg必填

    Footer word before the average time.

    string
  • previous必填

    Previous page button label.

    string
  • next必填

    Next page button label.

    string
  • range必填

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

    (from: number, to: number, total: number) => string
TopPagesFormatters5 个字段
  • count必填

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

    (value: number) => string
  • compact必填

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

    (value: number) => string
  • duration必填

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

    (seconds: number) => string
  • percent必填

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

    (value: number) => string
  • day必填

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

    (date: Date) => string
TopPagesBounceBands2 个字段
  • good必填

    Highest rate still shown as good.

    number
  • bad必填

    Lowest rate shown as bad.

    number
TopPagesToneClassNames3 个字段
  • good必填

    Rates at or under the good band.

    string
  • fair必填

    Rates between the bands.

    string
  • bad必填

    Rates at or over the bad band.

    string
TopPageStats8 个字段
  • views必填

    Page views in the period.

    number
  • visitors必填

    Unique visitors in the period.

    number
  • avgSeconds必填

    Average time on page, in seconds.

    number
  • bounceRate必填

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

    number
  • entryRate必填

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

    number
  • exitRate必填

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

    number
  • daily必填

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

    number[]
  • referrers必填

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

    TopPageReferrer[]
PageDetailColors4 个字段
  • bar必填

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

    string
  • stroke必填

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

    string
  • fill必填

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

    string
  • dot必填

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

    string
TopPagesViewRow2 个字段
  • page必填

    The page.

    TopPage
  • stats必填

    Its numbers for the selected period.

    TopPageStats
TopPageReferrer2 个字段
  • name必填

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

    string
  • visits必填

    Visits from this source in the period.

    number