Traffic Sources

1 variant

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

Install

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

API Reference

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

TrafficSources16 props
  • data

    Totals and rows for every period and grouping.

    TrafficSourcesData
  • period

    Controlled period.

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

    Period when uncontrolled.

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

    Default 30d

  • onPeriodChange

    Called when a period is chosen.

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

    Controlled grouping.

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

    Grouping when uncontrolled.

    "source" | "medium" | "campaign"

    Default source

  • onDimensionChange

    Called when a grouping is chosen.

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

    Most rows in the list.

    number

    Default 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 props
  • fromRequired

    Value in the previous period.

    number
  • toRequired

    Value in the selected period.

    number
  • variant

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

    "inline" | "pill"

    Default inline

  • className

    Classes merged onto the root element.

    string
SourceDetail7 props
  • idRequired

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

    string
  • pagesRequired

    Top landing pages for the row.

    TrafficLandingPage[]
  • totalRequired

    Row visitors, used for each page's share.

    number
  • headingRequired

    Heading above the pages.

    string
  • reduceRequired

    Skip movement, keep fades.

    boolean
  • formatNumberRequired

    Formats visitor counts.

    (value: number) => string
  • formatPercentRequired

    Formats each page's share of the row.

    (value: number) => string
SourceFavicon4 props
  • 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"
  • labelRequired

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

    string
  • className

    Classes merged onto the root element.

    string
SourceList13 props
  • rowsRequired

    Rows for the selected period and grouping.

    TrafficSourceRow[]
  • totalRequired

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

    number
  • periodRequired

    Selected period; a change redraws the sparklines.

    "7d" | "30d" | "90d"
  • dimensionRequired

    Selected grouping.

    "source" | "medium" | "campaign"
  • dimensionsRequired

    Groupings offered, in display order.

    TrafficDimension[]
  • onDimensionChangeRequired

    Called when a grouping tab is chosen.

    (dimension: TrafficDimension) => void
  • maxRowsRequired

    Most rows shown at once.

    number
  • reduceRequired

    Skip movement, keep fades.

    boolean
  • labelsRequired

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

    TrafficSourcesLabels
  • barClassNamesRequired

    Filled share bar class for each grouping.

    Record<TrafficDimension, string>
  • strokeClassNamesRequired

    Sparkline stroke class for each grouping.

    Record<TrafficDimension, string>
  • formatNumberRequired

    Formats visitor counts in the detail strip.

    (value: number) => string
  • formatPercentRequired

    Formats rates and shares.

    (value: number) => string
SourceRow14 props
  • rowRequired

    The row to draw.

    TrafficSourceRow
  • shareRequired

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

    number
  • visitShareRequired

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

    number
  • trendKeyRequired

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

    string
  • delayRequired

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

    number
  • reduceRequired

    Skip movement, keep fades.

    boolean
  • expandedRequired

    True while the landing pages strip is open.

    boolean
  • onToggleRequired

    Called when the row is clicked or activated by keyboard.

    () => void
  • barClassNameRequired

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

    string
  • strokeClassNameRequired

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

    string
  • labelsRequired

    Copy for the tooltip, toggle hint and detail heading.

    TrafficSourcesLabels
  • formatNumberRequired

    Formats visitor counts in the detail strip.

    (value: number) => string
  • formatPercentRequired

    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 props
  • totalRequired

    Totals for the selected period.

    TrafficPeriodTotal
  • periodRequired

    Selected period.

    "7d" | "30d" | "90d"
  • periodsRequired

    Periods offered, in display order.

    TrafficPeriod[]
  • periodLabelsRequired

    Tab label for each period.

    Record<TrafficPeriod, string>
  • onPeriodChangeRequired

    Called when a period is chosen.

    (period: TrafficPeriod) => void
  • labelsRequired

    Copy for the title, noun and change caption.

    TrafficSourcesLabels
Types5 types

The object types these props take, field by field.

TrafficFooterInfo4 fields
  • dimensionRequired

    Selected grouping.

    TrafficDimension
  • top

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

    TrafficSourceRow
  • shareRequired

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

    number
  • countRequired

    Number of rows in the selected grouping.

    number
TrafficSourcesLabels15 fields
  • titleRequired

    Card heading.

    string
  • visitorsRequired

    Noun after the total.

    string
  • deltaRequired

    Text after the change pill beside the total.

    string
  • periodsRequired

    Accessible name for the period tabs.

    string
  • dimensionsRequired

    Accessible name for the grouping tabs.

    string
  • sourceRequired

    Source tab label.

    string
  • mediumRequired

    Medium tab label.

    string
  • campaignRequired

    Campaign tab label.

    string
  • countRequired

    Right column heading in the list.

    string
  • bounceRequired

    Bounce rate label in the row tooltip.

    string
  • conversionRequired

    Conversion label in the row tooltip.

    string
  • shareRequired

    Share of visits label in the row tooltip.

    string
  • landingRequired

    Heading of the expanded landing pages strip.

    string
  • expandRequired

    Accessible hint on each row's toggle.

    string
  • emptyRequired

    Shown when the selected grouping has no rows.

    string
TrafficSourceRow10 fields
  • idRequired

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

    string
  • labelRequired

    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
  • visitorsRequired

    Visitors in the selected period.

    number
  • previousRequired

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

    number
  • bounceRateRequired

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

    number
  • conversionRateRequired

    Share of visits that converted, 0 to 1.

    number
  • trendRequired

    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 fields
  • pathRequired

    Page path, such as `/pricing`.

    string
  • visitorsRequired

    Visitors from this row who landed on the page.

    number
TrafficPeriodTotal2 fields
  • visitorsRequired

    All visitors in the period.

    number
  • previousRequired

    All visitors in the period before it.

    number