# Sparkline

Show a compact ordered trend with exact start, end and change context.

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

## When to use

- Use it when a page needs show a compact ordered trend with exact start, end and change context.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose analytics-card instead when explore revenue, compare periods and inspect chart values is the actual interface need, rather than sparkline.

## 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 Sparkline

```sh
npx shadcn@latest add @tidal-pro/sparkline
```

Stylesheets: `components/ui/tidal.css`, `components/ui/sparkline.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/sparkline.css";
import{TidalSparkline}from"./components/ui/sparkline";
export default()=><div className="tidal-scope"><TidalSparkline label={"Demo"} points={[{id:"example",label:"Demo",value:1}]}/></div>;
```

## Structured props

- `TidalSparkline.label: string`: Required label value accepted by this exported component.
- `TidalSparkline.points: ReadonlyArray<TidalSparklinePoint>`: Required points value accepted by this exported component.
- `TidalSparkline.activePointId?: string | null | undefined`: Optional active point id value accepted by this exported component.
- `TidalSparkline.changeContent?: ReactNode`: Optional change content value accepted by this exported component.
- `TidalSparkline.changeLabel?: string | undefined` (default "Change"): Optional change label value accepted by this exported component.
- `TidalSparkline.changeUnavailableText?: string | undefined` (default "Unavailable"): Optional change unavailable text value accepted by this exported component.
- `TidalSparkline.defaultActivePointId?: string | null | undefined` (default null): Optional default active point id value accepted by this exported component.
- `TidalSparkline.emptyContent?: ReactNode` (default "No finite values available."): Optional empty content value accepted by this exported component.
- `TidalSparkline.endLabel?: string | undefined` (default "End"): Optional end label value accepted by this exported component.
- `TidalSparkline.formatValue?: ((value: number) => string) | undefined` (default defaultFormatValue): Optional format value value accepted by this exported component.
- `TidalSparkline.inspectable?: boolean | undefined` (default false): Optional inspectable value accepted by this exported component.
- `TidalSparkline.onActivePointChange?: ((pointId: string, point: TidalSparklinePoint, source: TidalSparklineInspectSource, event: MouseEvent<HTMLButtonElement>) => void) | undefined`: Callback invoked when the active point change interaction is proposed.
- `TidalSparkline.startLabel?: string | undefined` (default "Start"): Optional start label value accepted by this exported component.
- `TidalSparkline.tableCaption?: string | undefined` (default "Exact trend values"): Optional table caption value accepted by this exported component.

## Complete usage example

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

```tsx
"use client";

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

import { useState } from "react";

import { TidalSparkline } from "./components/ui/sparkline";

import "./components/ui/sparkline.css";



const tidalExampleStyles = ".tidal-scope .sparkline-demo {\n  display: grid;\n  width: min(100%, 360px);\n  min-width: 0;\n  gap: 12px;\n  margin-inline: auto;\n}\n\n.tidal-scope .sparkline-demo > p {\n  min-width: 0;\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.45;\n  overflow-wrap: anywhere;\n}";

const SAMPLE_POINTS = [
  { id: "mon", label: "Monday", value: 18 },
  { id: "tue", label: "Tuesday", value: 23 },
  { id: "wed", label: "Wednesday", value: 21 },
  { id: "thu", label: "Thursday", value: 29 },
  { id: "fri", label: "Friday", value: 31 },
  { id: "sat", label: "Saturday", value: 27 },
  { id: "sun", label: "Sunday", value: 34 },
] as const;

export function SparklineDemo() {
  const [activePointId, setActivePointId] = useState<string>("mon");

  return (
    <section className="sparkline-demo" aria-label="Sparkline preview">
      <TidalSparkline
        label="Sample weekly activity"
        points={SAMPLE_POINTS}
        formatValue={(value) => `${value} items`}
        inspectable
        activePointId={activePointId}
        onActivePointChange={setActivePointId}
      />
      <p>Local sample values.</p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <SparklineDemo />
    </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."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Required string label and ordered {id,label,value} points. Optional formatValue, start/end/change labels, exact changeContent override, changeUnavailableText, tableCaption, emptyContent, inspectable previous/next controls, controlled activePointId, uncontrolled defaultActivePointId and onActivePointChange(pointId,point,source,event). Compatible native figure attributes, className and ref are forwarded; component-owned children and dangerouslySetInnerHTML are excluded and runtime markup is stripped. Nonfinite values and repeated IDs after the first are omitted and visibly counted. Straight segments connect only supplied finite observations; no intermediate values are generated. Consumers own data, formatting and controlled inspection acceptance.
