Skip to content

Dashboards

Overview screens: analytics, a conversion funnel, a usage report, a spend overview and a personal bank’s home.

Installation & usage

npx @youj/cli add app-analytics-overview

Also installs alert, app-page, badge, button, card, chart, counter, date-range-picker, empty, field, icon-pencil, reveal, skeleton, sparkline, stat-card, table, toggle-group, treemap, use-announcer, use-controllable-state, use-now, youj-core, youj-ui-core.

The CLI copies the block to blocks/app/analytics-overview.tsx with every component it uses, so it’s yours to edit.

Every prop is optional and falls back to the demo, so it renders as you see it until you pass your own. Give it your data, rewrite or translate its strings through copy, and connect its actions:

analyticsOverview-view.tsx
'use client'

import { AnalyticsOverview, type AnalyticsOverviewProps } from '@/blocks/app/analytics-overview'

export function AnalyticsOverviewView({ range, summary, kpis, metric }: Pick<AnalyticsOverviewProps, 'range' | 'summary' | 'kpis' | 'metric'>) {
  return (
    <AnalyticsOverview
      range={range}
      summary={summary}
      kpis={kpis}
      metric={metric}
      copy={{ title: 'Analytics overview' }}
      onRangeChange={(range) => {
        // your code
      }}
      onMetricChange={(metric) => {
        // your code
      }}
      onRetry={() => {
        // your code
      }}
    />
  )
}

Reference

Props22 props, 8 types

Props

AnalyticsOverview props
PropType
themeThemeInput

Wraps the block in this theme. Default: the theme around it.

–
embeddedboolean

A page in your app's frame: the shared page header (AppPage) and the frame's gutter, across the whole width, with no store header of its own.

default true

true
headingLevel1 | 2 | 3

The title's level.

default 1

1
rangeDateSpan

The span shown (controlled); pair it with onRangeChange.

–
defaultRangeDateSpan

The span shown first. Default: the last 30 days.

–
onRangeChange(range: DateSpan) => void

Called with each complete span the picker settles on.

–
summarySummary

The page's figures for the span shown, from your analytics API. Default: the demo store's, computed for the span.

–
kpisAnalyticsKpi[]

The headline numbers, in order.

default revenue, orders, conversion rate and average order

revenue, orders, conversion rate and average order
metricMetric
'revenue''orders''visitors'

The trend chart's metric (controlled); pair it with onMetricChange.

–
defaultMetricMetric
'revenue''orders''visitors'

The trend chart's first metric.

default 'revenue'

'revenue'
onMetricChange(metric: Metric) => void

Called with the metric the trend switch lands on.

–
todayDate | number

Today, the last day the picker offers. Default: the browser's today once mounted (a fixed demo day before, so hydration matches).

–
minDateDate

The first day the picker offers.

default the demo store's launch, Jan 6, 2025

the demo store's launch, Jan 6, 2025
currencystring

The currency of every amount.

default 'USD'

'USD'
localestring

Formats dates and numbers. Default: the YoujProvider locale.

–
brand{ name: string; logo?: ReactNode }

The store in the standalone header: its name and mark. Default: Fieldnote Supply and a pencil.

–
actionsReactNode

Beside the date picker: an export button, a filter. Default: none.

–
loadingboolean

Skeletons in place of the figures while your data loads; the layout holds.

default false

false
errorReactNode

Shown in place of the figures when they fail to load, with a retry button when onRetry is set. Default: none.

–
onRetry() => void

Retries loading after an error. Default: none.

–
emptyReactNode

Replaces the message for a span without visitors or orders. Default: copy.empty and copy.emptyDetail.

–
copyPartial<AnalyticsOverviewCopy>

Any of the page's strings, to rewrite or translate. Default: the demo's English strings.

–

AnalyticsCategory

AnalyticsCategory props
PropType
keyRequiredstring–
labelRequiredstring–
revenueRequirednumber–

AnalyticsChannel

AnalyticsChannel props
PropType
keyRequiredstring–
labelRequiredstring–
revenueRequirednumber–

AnalyticsKpi

AnalyticsKpi props
PropType
labelRequiredstring–
valueRequired(totals: Day) => number–
formatRequiredIntl.NumberFormatOptions

Money formats without a currency take the block's.

–
toneRequired'chart-1' | 'chart-2' | 'chart-3' | 'chart-4' | 'chart-5'–
barsboolean

Draws bars a bucket (sums and counts); without it a line (rates and averages).

–

AnalyticsDateSpan

AnalyticsDateSpan props
PropType
fromRequiredDate–
toRequiredDate–

AnalyticsDay

AnalyticsDay props
PropType
visitorsRequirednumber–
ordersRequirednumber–
revenueRequirednumber–

AnalyticsPoint

AnalyticsPoint props
PropType
labelRequiredstring

The axis label: an hour, a day, a week's first day or a month.

–
visitorsRequirednumber–
ordersRequirednumber–
revenueRequirednumber–

AnalyticsProduct

AnalyticsProduct props
PropType
idRequiredstring–
nameRequiredstring–
categoryRequiredstring

A category's key.

–
revenueRequirednumber

Revenue this period, in the block's currency.

–
unitsRequirednumber–
previousRequirednumber

Revenue in the period before.

–
trendRequirednumber[]

Revenue per bucket, for the row's sparkline.

–

AnalyticsSummary

AnalyticsSummary props
PropType
spanRequiredDateSpan–
previousSpanRequiredDateSpan–
daysRequirednumber–
unitRequired'hour' | 'day' | 'week' | 'month'

How the series is bucketed.

–
totalsRequiredDay–
previousTotalsRequiredDay–
seriesRequiredPoint[]–
previousSeriesRequiredPoint[]

The previous period, bucketed the same way and aligned by index.

–
channelsRequiredAnalyticsChannel[]

In legend order; each takes the next chart color.

–
productsRequiredProductRow[]

Ranked by revenue; the top five are listed.

–
categoriesRequiredAnalyticsCategory[]

Ranked by revenue; the first is highlighted.

–
Strings40 keys for copy

Strings

copy takes any of these keys; the rest keep their defaults. A key whose text holds a value (a count, a name) takes a function.

titlesectionbadgecomparedWithdateRangeannounceloadingemptyemptyDetailretrykpisvsPreviousbyUnitmetricmetricsoverTimeperagainstthisPeriodpreviousPeriodtrendSummaryperiodtrendCaptionchannelsTitlechannelsDescriptionchannelsSummarychannelsrevenueproductsTitleproductsDescriptionproductsTablerankproductunitschangetrendcategoriesTitlecategoriesLeadnoSalescategoriesLabel
Built from17 components
Accessibilitylandmarks, headings, loading

Accessibility

Each screen sits in a main or a labelled region with one page heading (headingLevel changes it), and its panels are labelled regions or sections (aria-labelledby) that set aria-busy while they load. Analytics and Funnel report add visually hidden text for loading, ranks, trends and empty cohort cells. Spend overview states its status in words (on track, or the day it will exceed the limit), names the forecast chart with a text summary, draws the request strip as one image that says how many requests failed, and lists the audit trail and the top spenders as ordered lists. Usage shows budget warnings as alerts and labels its spend-cap slider. Money overview names its balance and cards as regions, hides every amount behind a labeled toggle that reports its state, and reviews a payment in a drawer before it sends. Links and buttons are real a and button elements with the kit’s focus ring.