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
| Details | ||
|---|---|---|
| / | 38,420 | |
| /pricing | 21,960 | |
| /docs/getting-started | 17,340 | |
| /blog/edge-caching-notes | 14,870 | |
| /changelog | 11,200 | |
| /docs/api/events | 9,840 | |
| /integrations | 8,310 | |
| /signup | 7,650 |
1,284 pages · 412.3k views · avg 1m 42s
"use client";
import { TopPages } from "@/components/premium/top-pages";
export function TopPagesTablePreview() {
return (
<div className="w-full px-4 py-10">
<TopPages />
</div>
);
}
安装
API 参考
除标注为必填的属性外,其余均为可选。数据、文案和颜色默认使用示例内容。
TopPages15 个属性
pagesPages with their numbers for every period.
TopPage[]默认值
build()periodsPeriods for the tabs; ids key each page's `stats` and `totals`.
TopPagesPeriod[]periodControlled period id.
stringdefaultPeriodPeriod id when uncontrolled; defaults to the first period.
stringonPeriodChangeCalled when a period tab is chosen.
((period: string) => void)totalsSite totals per period id for the footer line.
Record<string, TopPagesTotals>endDateISO date of each period's last day, for the trend readout.
string默认值
2026-11-28defaultSortStarting sort.
TopPagesSortpageSizeRows per table page.
number默认值
8colorsBar, chart and accent color classes; anything left out keeps its default.
Partial<TopPagesColors>bounceBandsBounce rate bands for the good, fair and bad colors.
TopPagesBounceBandstoneClassNamesText color per bounce band; anything left out keeps its default.
Partial<TopPagesToneClassNames>formattersFormatter overrides; anything left out uses the defaults.
Partial<TopPagesFormatters>labelsCopy overrides; anything left out uses the English defaults.
Partial<TopPagesLabels>classNameClasses merged onto the root element.
string
PageDetail8 个属性
stats必填Numbers for the expanded page in the selected period.
TopPageStatsendDate必填ISO date of the period's last day.
stringlabels必填Copy for headings and captions.
TopPagesLabelsformatters必填Number, duration and rate formatters.
TopPagesFormatterscolors必填Chart and bar colors.
PageDetailColorsbounceBands必填Bounce rate bands for the narrow-width stats.
TopPagesBounceBandstoneClassNames必填Text color per bounce band.
TopPagesToneClassNamesreduce必填Skip movement, keep fades.
boolean
PageRow16 个属性
page必填The page.
TopPagestats必填Its numbers for the selected period.
TopPageStatsperiod必填Selected period id; the sparkline redraws when it changes.
stringshare必填Share bar width, views over the period's top page, 0 to 1.
numberexpanded必填Whether the detail below is open.
booleanonToggle必填Called to open or close the detail.
() => voiddetailId必填Id of the detail row, for `aria-controls`.
stringdelay必填Entrance delay in seconds; 0 for rows that arrive later.
numberlabels必填Copy for the expand button.
TopPagesLabelsformatters必填Number, duration and rate formatters.
TopPagesFormattersbarClassName必填Share bar class, such as `bg-sky-500/15`.
stringsparklineClassName必填Sparkline stroke class, such as `stroke-sky-500`.
stringbounceBands必填Bounce rate bands.
TopPagesBounceBandstoneClassNames必填Text color per bounce band.
TopPagesToneClassNamesreduce必填Skip movement, keep fades.
booleanrefThe 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.
stringtitle必填Heading above the chart, such as "Daily views".
stringunit必填Unit after the readout number, such as "views".
stringformatters必填Count and day formatters for the readout.
Pick<TopPagesFormatters, "count" | "day">strokeClassName必填Line color class, such as `stroke-sky-500`.
stringfillClassName必填Area color class, such as `fill-sky-500/15`.
stringdotClassName必填Dot color class for the hovered day, such as `bg-sky-500`.
stringreduce必填Skip the wipe and movement.
boolean
SortHeader7 个属性
column必填Column this header sorts.
"path" | "views" | "visitors" | "avgSeconds" | "bounceRate"label必填Header text.
stringsort必填Current sort.
TopPagesSortonSort必填Called with the column when the header is pressed.
(key: TopPagesSortKey) => voidnumericRight-align the label, for number columns.
boolean默认值
falsereduce必填Skip the chevron turn.
booleanclassNameWidth and visibility classes for the cell.
string
TopPagesEmpty4 个属性
title必填Title under the illustration.
stringhint必填Hint under the title.
stringaccentClassNameAccent class for the lens, such as `text-sky-500`.
string默认值
text-sky-500reduce必填Skip movement, keep fades.
boolean
TopPagesFooter9 个属性
totalsSite totals for the selected period, or undefined to hide the line.
TopPagesTotalsfrom必填First row shown, 1-based; 0 when nothing matches.
numberto必填Last row shown.
numbertotal必填Rows after filtering.
numberpage必填Current page, 0-based.
numberpageCount必填Number of pages.
numberonPageChange必填Called with the page to show.
(page: number) => voidlabels必填Copy for totals and pagination.
TopPagesLabelsformatters必填Number and duration formatters.
TopPagesFormatters
TopPagesHeader6 个属性
query必填Search text.
stringonQueryChange必填Called as the search text changes.
(query: string) => voidperiods必填Periods for the tabs.
TopPagesPeriod[]period必填Selected period id.
stringonPeriodChange必填Called when a period tab is chosen.
(period: string) => voidlabels必填Copy for the title, search and tabs.
TopPagesLabels
TopPagesTable16 个属性
rows必填Rows on the current page, already sorted.
TopPagesViewRow[]period必填Selected period id.
stringendDate必填ISO date of the period's last day.
stringmaxViews必填Largest view count in the period, for share bars.
numbersort必填Current sort.
TopPagesSortonSort必填Called when a header is pressed.
(key: TopPagesSortKey) => voidexpandedId必填Id of the expanded page, or null.
string | nullonExpandedChange必填Called to open (id) or close (null) a row's detail.
(id: string | null) => voidcascade必填Stagger rows in; true only for the first rows after mount.
booleanlabels必填Copy for headings and buttons.
TopPagesLabelsformatters必填Number, duration and rate formatters.
TopPagesFormatterscolors必填Bar, chart and sparkline colors.
PageDetailColors & { sparkline: string; }bounceBands必填Bounce rate bands.
TopPagesBounceBandstoneClassNames必填Text color per bounce band.
TopPagesToneClassNamesempty必填Shown in place of rows when nothing matches.
ReactNodereduce必填Skip movement, keep fades.
boolean
useTopPagesView6 个属性
pages必填Every page with its stats per period.
TopPage[]period必填Period whose stats are shown.
stringquery必填Search text that filters paths.
stringsort必填Column and direction to sort by.
TopPagesSortpage必填Zero-based page of results.
numberpageSize必填Rows per page.
number
类型13 个类型
这些属性使用的对象类型及其字段。
TopPagesColors6 个字段
bar必填Share bar behind paths and referrers.
stringsparkline必填Row sparkline stroke.
stringstroke必填Detail trend line stroke.
stringfill必填Detail trend area fill.
stringdot必填Hovered-day dot on the trend.
stringaccent必填Empty-state lens text color.
string
TopPagesSort2 个字段
key必填Column the rows are ordered by.
TopPagesSortKeydirection必填`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`.
stringlabel必填Tab text, such as "7d".
string
TopPage3 个字段
id必填Stable id.
stringpath必填URL path shown in mono, such as "/pricing".
stringstats必填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.
numberviews必填All page views in the period.
numberavgSeconds必填Average time on page across the site, in seconds.
number
TopPagesLabels28 个字段
title必填Card title.
stringsearch必填Search field placeholder.
stringsearchLabel必填Accessible name of the search field.
stringperiods必填Accessible name of the period tabs.
stringpage必填Page column heading.
stringviews必填Views column heading.
stringvisitors必填Visitors column heading.
stringavgTime必填Average time column heading.
stringbounceRate必填Bounce rate column heading.
stringtrend必填Trend column heading.
stringtable必填Accessible name of the table.
stringdetails必填Screen-reader heading of the expand column.
stringexpand必填Expand button label; receives the path.
(path: string) => stringcollapse必填Collapse button label; receives the path.
(path: string) => stringshow必填Expand button tooltip.
stringhide必填Collapse button tooltip.
stringdailyViews必填Detail chart heading.
stringreferrers必填Detail referrers heading.
stringentryRate必填Entry rate caption.
stringexitRate必填Exit rate caption.
stringemptyTitle必填Empty-search title.
stringemptyHint必填Empty-search hint; receives the query.
(query: string) => stringpages必填Footer word after the page total.
stringviewsTotal必填Footer word after the view total.
stringavg必填Footer word before the average time.
stringprevious必填Previous page button label.
stringnext必填Next page button label.
stringrange必填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) => stringcompact必填Short counts in the footer, such as "412k".
(value: number) => stringduration必填Seconds as a duration, such as "1m 42s".
(seconds: number) => stringpercent必填A 0 to 100 rate, such as "38%".
(value: number) => stringday必填A day in the trend readout, such as "Nov 24".
(date: Date) => string
TopPagesBounceBands2 个字段
good必填Highest rate still shown as good.
numberbad必填Lowest rate shown as bad.
number
TopPagesToneClassNames3 个字段
good必填Rates at or under the good band.
stringfair必填Rates between the bands.
stringbad必填Rates at or over the bad band.
string
TopPageStats8 个字段
views必填Page views in the period.
numbervisitors必填Unique visitors in the period.
numberavgSeconds必填Average time on page, in seconds.
numberbounceRate必填Share of single-page sessions that started here, 0 to 100.
numberentryRate必填Share of sessions that started on this page, 0 to 100.
numberexitRate必填Share of sessions that ended on this page, 0 to 100.
numberdaily必填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`.
stringstroke必填Trend line class, such as `stroke-sky-500`.
stringfill必填Trend area class, such as `fill-sky-500/15`.
stringdot必填Hovered-day dot class, such as `bg-sky-500`.
string
TopPagesViewRow2 个字段
page必填The page.
TopPagestats必填Its numbers for the selected period.
TopPageStats
TopPageReferrer2 个字段
name必填Source name, such as "google.com" or "Direct".
stringvisits必填Visits from this source in the period.
number