Dashral Pro is on the wayGet 30% off at launch

Dashral

Report header

A report's title with its live status, a period switcher, a date range, compare and export.

$ pnpm dlx shadcn@latest add @dashral/report-header

When to use

  • The heading of a report: its title and live status, a period and date range, compare, filters, share and export.
  • Analytics and finance pages where everything below follows the range and filters picked here.

When not to use

  • Pages that aren't a report, like settings or one record's details: a plain page heading is enough.
  • One chart with its own range: give the chart its own period switch, as Revenue chart does.

Usage

Report header with your own data: every prop has the sample as its default, so pass only what you have.

example.tsx
import { ReportHeader } from "@/components/dashral/blocks/report-header"

<ReportHeader
  title="Revenue"
  live
  onRangeChange={(range) => setRange(range)}
  onCompareChange={setCompare}
  filters={filters}
  onFiltersChange={setFilters}
  onExport={(format) => api.reports.export("revenue", format)}
  onShare={() => copyLink()}
/>

API reference

ReportHeader

A report's header: where it is, its title with a live status, and its controls — a period switcher that sets the date range (or pick any range, and the switcher lets go), compare with the previous period, export and share. The filters underneath can be removed one by one. Every part comes from props, and each control tells your handler.

PropTypeDefault
breadcrumb{ label: string; href?: string }[]sample
titleReact.ReactNode"Revenue"
liveboolean

The Live badge beside the title.

true
descriptionReact.ReactNodesample
defaultPeriodReportPeriod"30d"
onRangeChange(range: DateRange | undefined, period: ReportPeriod | null) => void

The dates picked, from the switcher (with its period) or the picker (with none).

—
compareboolean

Compare with the previous period (the header keeps it without it).

—
onCompareChange(compare: boolean) => void—
exports{ id: string; label: string; icon?: React.ReactNode }[]

The export menu's formats; none hides the button.

sample
onExport(id: string) => void—
onShare() => void—
filtersstring[]

The filters under the title (kept by the header without it); removing one tells onFiltersChange.

—
onFiltersChange(filters: string[]) => void—
onAddFilter() => void—

type ReportPeriod

= keyof typeof periods