# Analytics card

Explore revenue, compare periods and inspect chart values.

Access: pro. Category: Data. Kind: composite.

## When to use

- Use it when a page needs explore revenue, compare periods and inspect chart values.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose data-table instead when sortable column controls, native row selection and a scrollable table is the actual interface need, rather than analytics card.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Analytics card

```sh
npx shadcn@latest add @tidal-pro/analytics-card
```

Stylesheets: `components/ui/tidal.css`, `components/ui/analytics-card.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/analytics-card.css";
import{TidalAnalyticsCard}from"./components/ui/analytics-card";
export default()=><div className="tidal-scope"><TidalAnalyticsCard onPeriodChange={() => {}} period={"value"} periods={[{id:"example",label:"Demo",total:1,change:1,data:[{label:"Demo",value:1}]}]} title={"Demo"}/></div>;
```

## Structured props

- `TidalAnalyticsCard.onPeriodChange: (period: string) => void`: Callback invoked when the period change interaction is proposed.
- `TidalAnalyticsCard.period: string`: Required period value accepted by this exported component.
- `TidalAnalyticsCard.periods: Array<AnalyticsPeriod>`: Required periods value accepted by this exported component.
- `TidalAnalyticsCard.title: string`: Required title value accepted by this exported component.
- `TidalAnalyticsCard.className?: string | undefined` (default ""): Optional class name value accepted by this exported component.
- `TidalAnalyticsCard.formatValue?: ((value: number) => string) | undefined` (default defaultFormat): Optional format value value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/analytics-card.tsx) | [Manifest](https://tidalui.com/examples/analytics-card.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useState } from "react";

import { TidalAnalyticsCard } from "./components/ui/analytics-card";

import "./components/ui/analytics-card.css";

import "./components/ui/segmented-control.css";



function sampleDailyValues(count: number, total: number, start: string) {
  const weights = Array.from(
    { length: count },
    (_, i) =>
      0.7 +
      (i / count) * 0.6 +
      Math.sin(i * 1.9) * 0.16 +
      Math.cos(i * 0.45) * 0.1,
  );
  const sum = weights.reduce((a, b) => a + b, 0);
  const values = weights.map((weight) => Math.round((weight / sum) * total));
  values[values.length - 1] += total - values.reduce((a, b) => a + b, 0);
  return values.map((value, i) => {
    const date = new Date(start + "T12:00:00Z");
    date.setUTCDate(date.getUTCDate() + i);
    return {
      value,
      label: date.toLocaleDateString("en-US", {
        month: "short",
        day: "numeric",
        timeZone: "UTC",
      }),
    };
  });
}

const analyticsPeriods = [
  {
    id: "week",
    label: "7 days",
    total: 8240,
    change: 8.2,
    data: [900, 1060, 880, 1200, 1120, 1460, 1620].map((value, i) => ({
      value,
      label: "Oct " + (7 + i),
    })),
    comparison: sampleDailyValues(7, 7616, "2026-09-30"),
    breakdown: [
      { label: "Subscriptions", value: 5820 },
      { label: "One-time", value: 1820 },
      { label: "Usage", value: 600 },
    ],
  },
  {
    id: "month",
    label: "30 days",
    total: 32480,
    change: 14.8,
    data: sampleDailyValues(30, 32480, "2026-09-14"),
    comparison: sampleDailyValues(30, 28293, "2026-08-15"),
    breakdown: [
      { label: "Subscriptions", value: 23720 },
      { label: "One-time", value: 5910 },
      { label: "Usage", value: 2850 },
    ],
  },
  {
    id: "quarter",
    label: "90 days",
    total: 98640,
    change: 21.6,
    data: sampleDailyValues(90, 98640, "2026-07-16"),
    comparison: sampleDailyValues(90, 81118, "2026-04-17"),
    breakdown: [
      { label: "Subscriptions", value: 68060 },
      { label: "One-time", value: 21700 },
      { label: "Usage", value: 8880 },
    ],
  },
];

export function AnalyticsDemo() {
  const [period, setPeriod] = useState("month");
  return (
    <TidalAnalyticsCard
      title="Revenue overview"
      periods={analyticsPeriods}
      period={period}
      onPeriodChange={setPeriod}
      formatValue={(n) => "$" + n.toLocaleString("en-US")}
    />
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <AnalyticsDemo />
    </div>
  );
}

```

## Gotchas

- Supply truthful data and labels; the component does not fetch, aggregate, or persist records.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"The implementation includes reduced-motion behavior; verify it with the consumer's final content."}

title, periods ({id,label,total,change,data:{label,value}[],comparison?:{label,value}[],breakdown?:{label,value}[]}[]), controlled period, onPeriodChange. Optional formatValue and className. Continuous rolling values and interpolated chart geometry; mouse/pen and native range keyboard inspection. Optional previous-period comparison and category breakdown. View data expands an accessible table. Change is percent vs prior period. Empty periods render a no-data state. Finite values only. Sample daily totals and breakdowns reconcile in the demo. Reduced motion resolves immediately to the final state.
