Traffic Sources

1 个变体

An acquisition panel that shows where visitors come from by source, medium, or campaign, with favicons, share bars, and trend sparklines.

Source list

Where visitors come from by source, medium, or campaign over 7, 30, or 90 days, with real favicons, filled share bars, rolling counts, change deltas, and trend sparklines. Rows glide to their new rank when the period changes, and each row opens its bounce rate, conversion, and top landing pages.

Traffic sources

73,652visitorsup10%vs previous period
SourceVisitors
  • 26,048up11%
  • 15,243up9%
  • 6,749up18%
  • 5,900up38%
  • 5,126up4%
  • 3,765up7%

Top source google.com · 35% of visits · 12 sources

"use client";

import { TrafficSources } from "@/components/premium/traffic-sources";

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

安装

$ bunx --bun shadcn add @beui-pro/traffic-sources-list

API 参考

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

TrafficSources16 个属性
  • data

    Totals and rows for every period and grouping.

    TrafficSourcesData
  • period

    Controlled period.

    "7d" | "30d" | "90d"
  • defaultPeriod

    Period when uncontrolled.

    "7d" | "30d" | "90d"

    默认值 30d

  • onPeriodChange

    Called when a period is chosen.

    ((period: TrafficPeriod) => void)
  • dimension

    Controlled grouping.

    "source" | "medium" | "campaign"
  • defaultDimension

    Grouping when uncontrolled.

    "source" | "medium" | "campaign"

    默认值 source

  • onDimensionChange

    Called when a grouping is chosen.

    ((dimension: TrafficDimension) => void)
  • maxRows

    Most rows in the list.

    number

    默认值 6

  • periodLabels

    Period tab labels; any period left out keeps its default.

    Partial<Record<TrafficPeriod, string>>
  • barClassNames

    Filled share bar class for each grouping; any left out keeps its default.

    Partial<Record<TrafficDimension, string>>
  • strokeClassNames

    Sparkline stroke class for each grouping; any left out keeps its default.

    Partial<Record<TrafficDimension, string>>
  • formatNumber

    Formats visitor counts in the detail strip.

    ((value: number) => string)
  • formatPercent

    Formats rates and shares, given as 0 to 1.

    ((value: number) => string)
  • formatFooter

    Builds the footer line from the top row, its share and the row count.

    ((info: TrafficFooterInfo) => string)
  • labels

    Copy overrides; anything left out uses the English defaults.

    Partial<TrafficSourcesLabels>
  • className

    Classes merged onto the root element.

    string
ChangeDelta4 个属性
  • from必填

    Value in the previous period.

    number
  • to必填

    Value in the selected period.

    number
  • variant

    `pill` draws a tinted pill for the header; `inline` draws small colored text for rows.

    "inline" | "pill"

    默认值 inline

  • className

    Classes merged onto the root element.

    string
SourceDetail7 个属性
  • id必填

    Element id, referenced by the row toggle's `aria-controls`.

    string
  • pages必填

    Top landing pages for the row.

    TrafficLandingPage[]
  • total必填

    Row visitors, used for each page's share.

    number
  • heading必填

    Heading above the pages.

    string
  • reduce必填

    Skip movement, keep fades.

    boolean
  • formatNumber必填

    Formats visitor counts.

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

    Formats each page's share of the row.

    (value: number) => string
SourceFavicon4 个属性
  • domain

    Site domain to load the favicon for.

    string
  • icon

    Fallback icon when there is no domain or the favicon fails.

    "search" | "email" | "paid" | "campaign" | "direct" | "social" | "referral"
  • label必填

    Row label, used for the initial when there is no icon either.

    string
  • className

    Classes merged onto the root element.

    string
SourceList13 个属性
  • rows必填

    Rows for the selected period and grouping.

    TrafficSourceRow[]
  • total必填

    All visitors in the period, for each row's share of visits.

    number
  • period必填

    Selected period; a change redraws the sparklines.

    "7d" | "30d" | "90d"
  • dimension必填

    Selected grouping.

    "source" | "medium" | "campaign"
  • dimensions必填

    Groupings offered, in display order.

    TrafficDimension[]
  • onDimensionChange必填

    Called when a grouping tab is chosen.

    (dimension: TrafficDimension) => void
  • maxRows必填

    Most rows shown at once.

    number
  • reduce必填

    Skip movement, keep fades.

    boolean
  • labels必填

    Copy for tabs, headings, tooltip and the empty state.

    TrafficSourcesLabels
  • barClassNames必填

    Filled share bar class for each grouping.

    Record<TrafficDimension, string>
  • strokeClassNames必填

    Sparkline stroke class for each grouping.

    Record<TrafficDimension, string>
  • formatNumber必填

    Formats visitor counts in the detail strip.

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

    Formats rates and shares.

    (value: number) => string
SourceRow14 个属性
  • row必填

    The row to draw.

    TrafficSourceRow
  • share必填

    Bar width as a share of the largest row, 0 to 1.

    number
  • visitShare必填

    The row's share of all visitors in the period, 0 to 1, shown in the tooltip.

    number
  • trendKey必填

    Changes when the period changes, so the sparkline draws in again.

    string
  • delay必填

    Entrance delay in seconds; 0 for rows that join after the list opens.

    number
  • reduce必填

    Skip movement, keep fades.

    boolean
  • expanded必填

    True while the landing pages strip is open.

    boolean
  • onToggle必填

    Called when the row is clicked or activated by keyboard.

    () => void
  • barClassName必填

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

    string
  • strokeClassName必填

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

    string
  • labels必填

    Copy for the tooltip, toggle hint and detail heading.

    TrafficSourcesLabels
  • formatNumber必填

    Formats visitor counts in the detail strip.

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

    Formats rates in the tooltip.

    (value: number) => string
  • ref

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

    Ref<HTMLLIElement>
TrafficHeader6 个属性
  • total必填

    Totals for the selected period.

    TrafficPeriodTotal
  • period必填

    Selected period.

    "7d" | "30d" | "90d"
  • periods必填

    Periods offered, in display order.

    TrafficPeriod[]
  • periodLabels必填

    Tab label for each period.

    Record<TrafficPeriod, string>
  • onPeriodChange必填

    Called when a period is chosen.

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

    Copy for the title, noun and change caption.

    TrafficSourcesLabels
类型5 个类型

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

TrafficFooterInfo4 个字段
  • dimension必填

    Selected grouping.

    TrafficDimension
  • top

    The largest row, or undefined when the list is empty.

    TrafficSourceRow
  • share必填

    Top row's share of all visitors in the period, 0 to 1.

    number
  • count必填

    Number of rows in the selected grouping.

    number
TrafficSourcesLabels15 个字段
  • title必填

    Card heading.

    string
  • visitors必填

    Noun after the total.

    string
  • delta必填

    Text after the change pill beside the total.

    string
  • periods必填

    Accessible name for the period tabs.

    string
  • dimensions必填

    Accessible name for the grouping tabs.

    string
  • source必填

    Source tab label.

    string
  • medium必填

    Medium tab label.

    string
  • campaign必填

    Campaign tab label.

    string
  • count必填

    Right column heading in the list.

    string
  • bounce必填

    Bounce rate label in the row tooltip.

    string
  • conversion必填

    Conversion label in the row tooltip.

    string
  • share必填

    Share of visits label in the row tooltip.

    string
  • landing必填

    Heading of the expanded landing pages strip.

    string
  • expand必填

    Accessible hint on each row's toggle.

    string
  • empty必填

    Shown when the selected grouping has no rows.

    string
TrafficSourceRow10 个字段
  • id必填

    Stable id, used as the row key so rows glide between periods.

    string
  • label必填

    Domain, channel or campaign name shown in the row.

    string
  • domain

    Site domain; when set, the row shows that site's favicon.

    string
  • icon

    Fallback icon when there is no domain or the favicon fails to load.

    TrafficSourceIcon
  • visitors必填

    Visitors in the selected period.

    number
  • previous必填

    Visitors in the period before it, for the change figure.

    number
  • bounceRate必填

    Share of visits that left after one page, 0 to 1.

    number
  • conversionRate必填

    Share of visits that converted, 0 to 1.

    number
  • trend必填

    Visitors per day (or per bucket) across the period, oldest first.

    number[]
  • landingPages

    Top landing pages for this row, shown when the row is expanded.

    TrafficLandingPage[]
TrafficLandingPage2 个字段
  • path必填

    Page path, such as `/pricing`.

    string
  • visitors必填

    Visitors from this row who landed on the page.

    number
TrafficPeriodTotal2 个字段
  • visitors必填

    All visitors in the period.

    number
  • previous必填

    All visitors in the period before it.

    number