Top Pages
1 variantA 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>
);
}
Source code is locked
Get access to install premium components and view the full source.
Open dashboardInstall
API Reference
Every prop is optional unless marked required. Data, copy, and colors default to the sample content.
TopPages15 props
pagesPages with their numbers for every period.
TopPage[]Default
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.
stringDefault
2026-11-28defaultSortStarting sort.
TopPagesSortpageSizeRows per table page.
numberDefault
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 props
statsRequiredNumbers for the expanded page in the selected period.
TopPageStatsendDateRequiredISO date of the period's last day.
stringlabelsRequiredCopy for headings and captions.
TopPagesLabelsformattersRequiredNumber, duration and rate formatters.
TopPagesFormatterscolorsRequiredChart and bar colors.
PageDetailColorsbounceBandsRequiredBounce rate bands for the narrow-width stats.
TopPagesBounceBandstoneClassNamesRequiredText color per bounce band.
TopPagesToneClassNamesreduceRequiredSkip movement, keep fades.
boolean
PageRow16 props
pageRequiredThe page.
TopPagestatsRequiredIts numbers for the selected period.
TopPageStatsperiodRequiredSelected period id; the sparkline redraws when it changes.
stringshareRequiredShare bar width, views over the period's top page, 0 to 1.
numberexpandedRequiredWhether the detail below is open.
booleanonToggleRequiredCalled to open or close the detail.
() => voiddetailIdRequiredId of the detail row, for `aria-controls`.
stringdelayRequiredEntrance delay in seconds; 0 for rows that arrive later.
numberlabelsRequiredCopy for the expand button.
TopPagesLabelsformattersRequiredNumber, duration and rate formatters.
TopPagesFormattersbarClassNameRequiredShare bar class, such as `bg-sky-500/15`.
stringsparklineClassNameRequiredSparkline stroke class, such as `stroke-sky-500`.
stringbounceBandsRequiredBounce rate bands.
TopPagesBounceBandstoneClassNamesRequiredText color per bounce band.
TopPagesToneClassNamesreduceRequiredSkip movement, keep fades.
booleanrefThe row element, so AnimatePresence can pop exiting rows out of the flow.
Ref<HTMLTableRowElement>
PageTrend9 props
valuesRequiredViews per day, oldest first.
number[]endDateRequiredISO date of the last value.
stringtitleRequiredHeading above the chart, such as "Daily views".
stringunitRequiredUnit after the readout number, such as "views".
stringformattersRequiredCount and day formatters for the readout.
Pick<TopPagesFormatters, "count" | "day">strokeClassNameRequiredLine color class, such as `stroke-sky-500`.
stringfillClassNameRequiredArea color class, such as `fill-sky-500/15`.
stringdotClassNameRequiredDot color class for the hovered day, such as `bg-sky-500`.
stringreduceRequiredSkip the wipe and movement.
boolean
SortHeader7 props
columnRequiredColumn this header sorts.
"path" | "views" | "visitors" | "avgSeconds" | "bounceRate"labelRequiredHeader text.
stringsortRequiredCurrent sort.
TopPagesSortonSortRequiredCalled with the column when the header is pressed.
(key: TopPagesSortKey) => voidnumericRight-align the label, for number columns.
booleanDefault
falsereduceRequiredSkip the chevron turn.
booleanclassNameWidth and visibility classes for the cell.
string
TopPagesEmpty4 props
titleRequiredTitle under the illustration.
stringhintRequiredHint under the title.
stringaccentClassNameAccent class for the lens, such as `text-sky-500`.
stringDefault
text-sky-500reduceRequiredSkip movement, keep fades.
boolean
TopPagesFooter9 props
totalsSite totals for the selected period, or undefined to hide the line.
TopPagesTotalsfromRequiredFirst row shown, 1-based; 0 when nothing matches.
numbertoRequiredLast row shown.
numbertotalRequiredRows after filtering.
numberpageRequiredCurrent page, 0-based.
numberpageCountRequiredNumber of pages.
numberonPageChangeRequiredCalled with the page to show.
(page: number) => voidlabelsRequiredCopy for totals and pagination.
TopPagesLabelsformattersRequiredNumber and duration formatters.
TopPagesFormatters
TopPagesHeader6 props
queryRequiredSearch text.
stringonQueryChangeRequiredCalled as the search text changes.
(query: string) => voidperiodsRequiredPeriods for the tabs.
TopPagesPeriod[]periodRequiredSelected period id.
stringonPeriodChangeRequiredCalled when a period tab is chosen.
(period: string) => voidlabelsRequiredCopy for the title, search and tabs.
TopPagesLabels
TopPagesTable16 props
rowsRequiredRows on the current page, already sorted.
TopPagesViewRow[]periodRequiredSelected period id.
stringendDateRequiredISO date of the period's last day.
stringmaxViewsRequiredLargest view count in the period, for share bars.
numbersortRequiredCurrent sort.
TopPagesSortonSortRequiredCalled when a header is pressed.
(key: TopPagesSortKey) => voidexpandedIdRequiredId of the expanded page, or null.
string | nullonExpandedChangeRequiredCalled to open (id) or close (null) a row's detail.
(id: string | null) => voidcascadeRequiredStagger rows in; true only for the first rows after mount.
booleanlabelsRequiredCopy for headings and buttons.
TopPagesLabelsformattersRequiredNumber, duration and rate formatters.
TopPagesFormatterscolorsRequiredBar, chart and sparkline colors.
PageDetailColors & { sparkline: string; }bounceBandsRequiredBounce rate bands.
TopPagesBounceBandstoneClassNamesRequiredText color per bounce band.
TopPagesToneClassNamesemptyRequiredShown in place of rows when nothing matches.
ReactNodereduceRequiredSkip movement, keep fades.
boolean
useTopPagesView6 props
pagesRequiredEvery page with its stats per period.
TopPage[]periodRequiredPeriod whose stats are shown.
stringqueryRequiredSearch text that filters paths.
stringsortRequiredColumn and direction to sort by.
TopPagesSortpageRequiredZero-based page of results.
numberpageSizeRequiredRows per page.
number
Types13 types
The object types these props take, field by field.
TopPagesColors6 fields
barRequiredShare bar behind paths and referrers.
stringsparklineRequiredRow sparkline stroke.
stringstrokeRequiredDetail trend line stroke.
stringfillRequiredDetail trend area fill.
stringdotRequiredHovered-day dot on the trend.
stringaccentRequiredEmpty-state lens text color.
string
TopPagesSort2 fields
keyRequiredColumn the rows are ordered by.
TopPagesSortKeydirectionRequired`desc` puts the largest value (or Z for paths) first.
"asc" | "desc"
TopPagesPeriod2 fields
idRequiredStable id, used as the key into each page's `stats`.
stringlabelRequiredTab text, such as "7d".
string
TopPage3 fields
idRequiredStable id.
stringpathRequiredURL path shown in mono, such as "/pricing".
stringstatsRequiredNumbers keyed by period id. Pages missing a period are hidden in it.
Record<string, TopPageStats>
TopPagesTotals3 fields
pagesRequiredPages with at least one view in the period.
numberviewsRequiredAll page views in the period.
numberavgSecondsRequiredAverage time on page across the site, in seconds.
number
TopPagesLabels28 fields
titleRequiredCard title.
stringsearchRequiredSearch field placeholder.
stringsearchLabelRequiredAccessible name of the search field.
stringperiodsRequiredAccessible name of the period tabs.
stringpageRequiredPage column heading.
stringviewsRequiredViews column heading.
stringvisitorsRequiredVisitors column heading.
stringavgTimeRequiredAverage time column heading.
stringbounceRateRequiredBounce rate column heading.
stringtrendRequiredTrend column heading.
stringtableRequiredAccessible name of the table.
stringdetailsRequiredScreen-reader heading of the expand column.
stringexpandRequiredExpand button label; receives the path.
(path: string) => stringcollapseRequiredCollapse button label; receives the path.
(path: string) => stringshowRequiredExpand button tooltip.
stringhideRequiredCollapse button tooltip.
stringdailyViewsRequiredDetail chart heading.
stringreferrersRequiredDetail referrers heading.
stringentryRateRequiredEntry rate caption.
stringexitRateRequiredExit rate caption.
stringemptyTitleRequiredEmpty-search title.
stringemptyHintRequiredEmpty-search hint; receives the query.
(query: string) => stringpagesRequiredFooter word after the page total.
stringviewsTotalRequiredFooter word after the view total.
stringavgRequiredFooter word before the average time.
stringpreviousRequiredPrevious page button label.
stringnextRequiredNext page button label.
stringrangeRequiredRange text, such as "1–8 of 24".
(from: number, to: number, total: number) => string
TopPagesFormatters5 fields
countRequiredFull counts in cells and readouts, such as "21,960".
(value: number) => stringcompactRequiredShort counts in the footer, such as "412k".
(value: number) => stringdurationRequiredSeconds as a duration, such as "1m 42s".
(seconds: number) => stringpercentRequiredA 0 to 100 rate, such as "38%".
(value: number) => stringdayRequiredA day in the trend readout, such as "Nov 24".
(date: Date) => string
TopPagesBounceBands2 fields
goodRequiredHighest rate still shown as good.
numberbadRequiredLowest rate shown as bad.
number
TopPagesToneClassNames3 fields
goodRequiredRates at or under the good band.
stringfairRequiredRates between the bands.
stringbadRequiredRates at or over the bad band.
string
TopPageStats8 fields
viewsRequiredPage views in the period.
numbervisitorsRequiredUnique visitors in the period.
numberavgSecondsRequiredAverage time on page, in seconds.
numberbounceRateRequiredShare of single-page sessions that started here, 0 to 100.
numberentryRateRequiredShare of sessions that started on this page, 0 to 100.
numberexitRateRequiredShare of sessions that ended on this page, 0 to 100.
numberdailyRequiredViews per day, oldest first; the last value is the period's end date.
number[]referrersRequiredTop sources for this page, largest first. The detail shows the first three.
TopPageReferrer[]
PageDetailColors4 fields
barRequiredShare bar class behind referrer names, such as `bg-sky-500/15`.
stringstrokeRequiredTrend line class, such as `stroke-sky-500`.
stringfillRequiredTrend area class, such as `fill-sky-500/15`.
stringdotRequiredHovered-day dot class, such as `bg-sky-500`.
string
TopPagesViewRow2 fields
pageRequiredThe page.
TopPagestatsRequiredIts numbers for the selected period.
TopPageStats
TopPageReferrer2 fields
nameRequiredSource name, such as "google.com" or "Direct".
stringvisitsRequiredVisits from this source in the period.
number