# Tooltip Chart

Ten chart tooltips for React, from the default indicator to dashed and line markers, icons, custom formatters and fully custom markup.

Tooltip Chart is an open-source chart from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.

Source: https://suiss.app/ui/docs/charts/tooltip-chart

Every chart shares one tooltip, and these variants show how to change it. Pick an indicator style, hide the indicator or the label, format values and headings with your own functions, show an icon per series, or replace the content with your own markup. The interactive variant lets you try the options on one chart.

These tooltips are the `ChartTooltipContent` of the [Chart](https://suiss.app/ui/docs/components/chart) component, used inside charts built on [Card](https://suiss.app/ui/docs/components/card).

Every variant below is its own registry item, so you can add only the ones you need.


## Tooltip Chart Dot

A stacked bar chart showing the default tooltip indicator, a small colored square for each series.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#dot

**React**

**Example**

```tsx title="components/charts/tooltip-chart-dot.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartDot() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Dot indicator</CardTitle>
        <CardDescription>The default</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent indicator="dot" />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A stacked bar chart that shows the default tooltip indicator, a small colored square beside each series. It is the most compact indicator and the one you get without setting anything.

Leave `indicator` on `ChartTooltipContent` unset or set it to `dot`. Replace `chartData` and the series in `chartConfig` with your own. The tooltip opens on a preset month when the chart loads; remove `defaultIndex` if it should start hidden.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-dot
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-dot
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-dot.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartDot() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Dot indicator</CardTitle>
        <CardDescription>The default</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent indicator="dot" />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartDot } from "@/components/charts/tooltip-chart-dot"
```

```tsx
<TooltipChartDot />
```



## Tooltip Chart Custom

A bar chart whose tooltip is fully custom markup, showing a large total, a unit and the day.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#custom

**React**

**Example**

```tsx title="components/charts/tooltip-chart-custom.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
} from "@/components/ui/chart"

const chartData = [
  { day: "Monday", steps: 8412 },
  { day: "Tuesday", steps: 10230 },
  { day: "Wednesday", steps: 6120 },
  { day: "Thursday", steps: 12480 },
  { day: "Friday", steps: 9050 },
  { day: "Saturday", steps: 14320 },
  { day: "Sunday", steps: 4870 },
]

const chartConfig = {
  steps: { label: "Steps", color: "var(--chart-4)" },
} satisfies ChartConfig

export function TooltipChartCustom() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Custom content</CardTitle>
        <CardDescription>A tooltip built from scratch</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="day"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={5}
              cursor={false}
              content={({ active, payload, label }) => {
                const entry = payload?.[0]
                if (!active || !entry) return null
                return (
                  <div className="min-w-28 rounded-xl bg-popover px-3 py-2 shadow-lg ring-1 ring-foreground/5 dark:ring-foreground/10">
                    <p className="text-xs font-semibold tracking-wide text-muted-foreground uppercase">
                      Total
                    </p>
                    <p className="flex items-baseline gap-1">
                      <span className="text-2xl font-semibold tabular-nums">
                        {Number(entry.value).toLocaleString("en-US")}
                      </span>
                      <span className="text-xs font-semibold text-muted-foreground">
                        steps
                      </span>
                    </p>
                    <p className="text-xs text-muted-foreground">{label}</p>
                  </div>
                )
              }}
            />
            <Bar
              dataKey="steps"
              fill="var(--color-steps)"
              radius={4}
              maxBarSize={26}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A step-count bar chart whose tooltip is built from scratch as a small card with a big number, unit and day name. Reach for it when the stock tooltip layout can't express what you need, such as a single headline value.

Pass a render function to the `content` prop of `ChartTooltip`; it receives the active state, the hovered rows and the label, and returns null when inactive. A custom tooltip replaces the built-in one, so config labels and colors appear only if you read them yourself. The tooltip opens on a preset bar when the chart loads; remove `defaultIndex` if it should start hidden.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-custom
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-custom
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-custom.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
} from "@/components/ui/chart"

const chartData = [
  { day: "Monday", steps: 8412 },
  { day: "Tuesday", steps: 10230 },
  { day: "Wednesday", steps: 6120 },
  { day: "Thursday", steps: 12480 },
  { day: "Friday", steps: 9050 },
  { day: "Saturday", steps: 14320 },
  { day: "Sunday", steps: 4870 },
]

const chartConfig = {
  steps: { label: "Steps", color: "var(--chart-4)" },
} satisfies ChartConfig

export function TooltipChartCustom() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Custom content</CardTitle>
        <CardDescription>A tooltip built from scratch</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="day"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={5}
              cursor={false}
              content={({ active, payload, label }) => {
                const entry = payload?.[0]
                if (!active || !entry) return null
                return (
                  <div className="min-w-28 rounded-xl bg-popover px-3 py-2 shadow-lg ring-1 ring-foreground/5 dark:ring-foreground/10">
                    <p className="text-xs font-semibold tracking-wide text-muted-foreground uppercase">
                      Total
                    </p>
                    <p className="flex items-baseline gap-1">
                      <span className="text-2xl font-semibold tabular-nums">
                        {Number(entry.value).toLocaleString("en-US")}
                      </span>
                      <span className="text-xs font-semibold text-muted-foreground">
                        steps
                      </span>
                    </p>
                    <p className="text-xs text-muted-foreground">{label}</p>
                  </div>
                )
              }}
            />
            <Bar
              dataKey="steps"
              fill="var(--color-steps)"
              radius={4}
              maxBarSize={26}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartCustom } from "@/components/charts/tooltip-chart-custom"
```

```tsx
<TooltipChartCustom />
```



## Tooltip Chart Dashed

A stacked bar chart whose tooltip marks each series with a dashed outline indicator.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#dashed

**React**

**Example**

```tsx title="components/charts/tooltip-chart-dashed.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartDashed() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Dashed indicator</CardTitle>
        <CardDescription>indicator=&quot;dashed&quot;</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent indicator="dashed" />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A stacked bar chart that shows the dashed tooltip indicator, which marks each series with a dashed outline in its color. Compare it with the dot and line variants to pick the indicator that fits your design.

Set `indicator` on `ChartTooltipContent` to `dashed`; it works on any chart. Replace `chartData` and the series in `chartConfig` with your own. The tooltip opens on a preset month when the chart loads; remove `defaultIndex` if it should start hidden.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-dashed
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-dashed
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-dashed.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartDashed() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Dashed indicator</CardTitle>
        <CardDescription>indicator=&quot;dashed&quot;</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent indicator="dashed" />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartDashed } from "@/components/charts/tooltip-chart-dashed"
```

```tsx
<TooltipChartDashed />
```



## Tooltip Chart Formatter

A bar chart of daily active energy whose tooltip shows a name, value and kcal unit through a custom formatter.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#formatter

**React**

**Example**

```tsx title="components/charts/tooltip-chart-formatter.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

function dayKey(date: Date) {
  return [
    date.getFullYear(),
    String(date.getMonth() + 1).padStart(2, "0"),
    String(date.getDate()).padStart(2, "0"),
  ].join("-")
}

const chartData = [
  512, 604, 455, 389, 662, 598, 431, 520, 690, 447, 575, 402, 633, 558,
]
  .slice(-7)
  .map((energy, index) => ({
    date: dayKey(new Date(2026, 9, index)),
    energy,
  }))

const chartConfig = {
  energy: { label: "Active energy", color: "var(--color-red-500)" },
} satisfies ChartConfig

const weekday = new Intl.DateTimeFormat("en-US", { weekday: "short" })

export function TooltipChartFormatter() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>With units</CardTitle>
        <CardDescription>A unit next to the value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="date"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) =>
                weekday.format(new Date(`${value}T12:00:00`))
              }
            />
            <ChartTooltip
              defaultIndex={3}
              cursor={false}
              content={
                <ChartTooltipContent
                  hideLabel
                  formatter={(value) => (
                    <div className="flex items-baseline gap-1.5">
                      <span className="text-muted-foreground">
                        Active energy
                      </span>
                      <span className="font-semibold text-foreground tabular-nums">
                        {Number(value).toLocaleString("en-US")}
                      </span>
                      <span className="text-xs text-muted-foreground">
                        kcal
                      </span>
                    </div>
                  )}
                />
              }
            />
            <Bar
              dataKey="energy"
              fill="var(--color-energy)"
              radius={4}
              maxBarSize={26}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A week of active-energy bars whose tooltip row is rewritten by a formatter to show a name, value and kcal unit. Use a formatter like this when values need units, thousands separators or extra context.

Pass a `formatter` to `ChartTooltipContent`; it receives each row's value and name and returns the markup for that row, where you set the label, number format and unit. Dates are parsed at noon so the weekday labels don't shift a day in time zones behind UTC; keep that if you use date strings as categories.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-formatter
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-formatter
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-formatter.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

function dayKey(date: Date) {
  return [
    date.getFullYear(),
    String(date.getMonth() + 1).padStart(2, "0"),
    String(date.getDate()).padStart(2, "0"),
  ].join("-")
}

const chartData = [
  512, 604, 455, 389, 662, 598, 431, 520, 690, 447, 575, 402, 633, 558,
]
  .slice(-7)
  .map((energy, index) => ({
    date: dayKey(new Date(2026, 9, index)),
    energy,
  }))

const chartConfig = {
  energy: { label: "Active energy", color: "var(--color-red-500)" },
} satisfies ChartConfig

const weekday = new Intl.DateTimeFormat("en-US", { weekday: "short" })

export function TooltipChartFormatter() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>With units</CardTitle>
        <CardDescription>A unit next to the value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="date"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) =>
                weekday.format(new Date(`${value}T12:00:00`))
              }
            />
            <ChartTooltip
              defaultIndex={3}
              cursor={false}
              content={
                <ChartTooltipContent
                  hideLabel
                  formatter={(value) => (
                    <div className="flex items-baseline gap-1.5">
                      <span className="text-muted-foreground">
                        Active energy
                      </span>
                      <span className="font-semibold text-foreground tabular-nums">
                        {Number(value).toLocaleString("en-US")}
                      </span>
                      <span className="text-xs text-muted-foreground">
                        kcal
                      </span>
                    </div>
                  )}
                />
              }
            />
            <Bar
              dataKey="energy"
              fill="var(--color-energy)"
              radius={4}
              maxBarSize={26}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartFormatter } from "@/components/charts/tooltip-chart-formatter"
```

```tsx
<TooltipChartFormatter />
```



## Tooltip Chart Icons

A stacked bar chart whose tooltip shows an icon for each series in place of a color swatch.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#icons

**React**

**Example**

```tsx title="components/charts/tooltip-chart-icons.tsx"
"use client"

import { DesktopIcon, DeviceMobileIcon } from "@phosphor-icons/react"
import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: {
    label: "Desktop",
    color: "var(--chart-1)",
    icon: () => (
      <DesktopIcon />
    ),
  },
  mobile: {
    label: "Mobile",
    color: "var(--chart-2)",
    icon: () => (
      <DeviceMobileIcon />
    ),
  },
} satisfies ChartConfig

export function TooltipChartIcons() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>With icons</CardTitle>
        <CardDescription>An icon instead of a color</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={3}
              cursor={false}
              content={<ChartTooltipContent />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A stacked bar chart whose tooltip shows a small icon for each series instead of a color swatch. Use icons when series map to recognizable things, like device types, and color alone isn't enough to tell them apart.

Add an `icon` component to each series entry in `chartConfig`; the tooltip picks it up. Icons replace the color indicator in every tooltip and legend that uses this config, so add them only where you want them everywhere. The tooltip opens on a preset month when the chart loads.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-icons
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-icons
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install @phosphor-icons/react recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-icons.tsx"
"use client"

import { DesktopIcon, DeviceMobileIcon } from "@phosphor-icons/react"
import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: {
    label: "Desktop",
    color: "var(--chart-1)",
    icon: () => (
      <DesktopIcon />
    ),
  },
  mobile: {
    label: "Mobile",
    color: "var(--chart-2)",
    icon: () => (
      <DeviceMobileIcon />
    ),
  },
} satisfies ChartConfig

export function TooltipChartIcons() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>With icons</CardTitle>
        <CardDescription>An icon instead of a color</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={3}
              cursor={false}
              content={<ChartTooltipContent />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartIcons } from "@/components/charts/tooltip-chart-icons"
```

```tsx
<TooltipChartIcons />
```



## Tooltip Chart Interactive

A tooltip playground on quarterly revenue bars, with controls for indicator, trigger, title total and hidden parts.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#interactive

**React**

**Example**

```tsx title="components/charts/tooltip-chart-interactive.tsx"
"use client"

import * as React from "react"
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts"

import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"
import { Switch } from "@/components/ui/switch"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

type Indicator = "dot" | "line" | "dashed"

type Trigger = "hover" | "click"

const chartData = [
  ["Q1 25", 69.1, 9, 26.3],
  ["Q2 25", 46.8, 8, 26.6],
  ["Q3 25", 44.6, 8, 27.4],
  ["Q4 25", 46.2, 8.7, 28.8],
  ["Q1 26", 71, 9.5, 29.1],
  ["Q2 26", 49.4, 8.6, 29.4],
  ["Q3 26", 47.3, 8.9, 30.1],
  ["Q4 26", 49, 9.3, 31.2],
].map(([quarter, phones, laptops, services]) => ({
  quarter: quarter as string,
  phones: phones as number,
  laptops: laptops as number,
  services: services as number,
}))

const chartConfig = {
  phones: { label: "Phones", color: "var(--chart-1)" },
  laptops: { label: "Laptops", color: "var(--chart-2)" },
  services: { label: "Services", color: "var(--color-purple-500)" },
} satisfies ChartConfig

const INDICATORS: Record<Indicator, string> = {
  dot: "Dot",
  line: "Line",
  dashed: "Dashed",
}

const TRIGGERS: Record<Trigger, string> = {
  hover: "On hover",
  click: "On click",
}

const billions = new Intl.NumberFormat("en-US", {
  minimumFractionDigits: 1,
  maximumFractionDigits: 1,
})

function Setting({
  label,
  checked,
  onCheckedChange,
}: {
  label: string
  checked: boolean
  onCheckedChange: (checked: boolean) => void
}) {
  const id = React.useId()

  return (
    <div className="flex items-center gap-2.5 text-sm">
      <Switch id={id} checked={checked} onCheckedChange={onCheckedChange} />
      <label htmlFor={id}>{label}</label>
    </div>
  )
}

export function TooltipChartInteractive() {
  const [indicator, setIndicator] = React.useState<Indicator>("dot")
  const [trigger, setTrigger] = React.useState<Trigger>("hover")
  const [showTotal, setShowTotal] = React.useState(true)
  const [hideLabel, setHideLabel] = React.useState(false)
  const [hideIndicator, setHideIndicator] = React.useState(false)

  return (
    <Card variant="filled" size="sm" className="[--card-spacing:--spacing(5)]">
      <CardHeader className="gap-0.5">
        <p className="text-lg font-semibold">Tooltip settings</p>
        <p className="text-sm text-muted-foreground">
          Quarterly revenue · billions · sample data. Change the settings and
          point at the bars.
        </p>
      </CardHeader>
      <CardContent className="flex flex-col gap-5">
        <div className="flex flex-wrap items-end gap-x-6 gap-y-3">
          <div className="flex flex-col gap-1.5">
            <span className="text-xs font-semibold text-muted-foreground">
              Indicator
            </span>
            <ToggleGroup
              spacing={0}
              value={[indicator]}
              onValueChange={(value: string[]) => {
                if (value[0]) setIndicator(value[0] as Indicator)
              }}
              aria-label="Indicator"
            >
              {(Object.keys(INDICATORS) as Indicator[]).map((key) => (
                <ToggleGroupItem key={key} value={key} size="sm">
                  {INDICATORS[key]}
                </ToggleGroupItem>
              ))}
            </ToggleGroup>
          </div>
          <div className="flex flex-col gap-1.5">
            <span className="text-xs font-semibold text-muted-foreground">
              Trigger
            </span>
            <ToggleGroup
              spacing={0}
              value={[trigger]}
              onValueChange={(value: string[]) => {
                if (value[0]) setTrigger(value[0] as Trigger)
              }}
              aria-label="Trigger"
            >
              {(Object.keys(TRIGGERS) as Trigger[]).map((key) => (
                <ToggleGroupItem key={key} value={key} size="sm">
                  {TRIGGERS[key]}
                </ToggleGroupItem>
              ))}
            </ToggleGroup>
          </div>
          <div className="flex flex-wrap gap-x-5 gap-y-2.5 pb-1">
            <Setting
              label="Total in title"
              checked={showTotal}
              onCheckedChange={setShowTotal}
            />
            <Setting
              label="Hide title"
              checked={hideLabel}
              onCheckedChange={setHideLabel}
            />
            <Setting
              label="Hide indicator"
              checked={hideIndicator}
              onCheckedChange={setHideIndicator}
            />
          </div>
        </div>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-72 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="quarter"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              minTickGap={8}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              tickFormatter={(value: number) => `${value}B`}
            />
            <ChartTooltip
              key={trigger}
              trigger={trigger}
              defaultIndex={4}
              cursor={false}
              content={
                <ChartTooltipContent
                  indicator={indicator}
                  hideLabel={hideLabel}
                  hideIndicator={hideIndicator}
                  labelFormatter={
                    showTotal
                      ? (label, payload) => (
                          <div className="flex justify-between gap-4">
                            <span>{label}</span>
                            <span className="tabular-nums">
                              {billions.format(
                                payload.reduce(
                                  (sum, item) => sum + Number(item.value ?? 0),
                                  0
                                )
                              )}
                              B
                            </span>
                          </div>
                        )
                      : undefined
                  }
                />
              }
            />
            <ChartLegend content={<ChartLegendContent />} />
            <Bar
              dataKey="services"
              stackId="a"
              fill="var(--color-services)"
              radius={[0, 0, 4, 4]}
              maxBarSize={44}
            />
            <Bar
              dataKey="laptops"
              stackId="a"
              fill="var(--color-laptops)"
              maxBarSize={44}
            />
            <Bar
              dataKey="phones"
              stackId="a"
              fill="var(--color-phones)"
              radius={[4, 4, 0, 0]}
              maxBarSize={44}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A stacked quarterly revenue chart with live controls for every tooltip option: indicator style, hover or click trigger, a total in the title, and hiding the title or indicator. Use it to try combinations before copying the settings into your own chart.

Copy the props of the combination you like into your chart: `indicator`, `hideLabel` and `hideIndicator` go on the tooltip content, and `trigger` on `ChartTooltip`. The total in the title comes from a label formatter that sums the rows. With the click trigger, the tooltip appears after a bar is clicked and stays in place as the pointer moves. Every control is a labeled switch or toggle group that works with the keyboard.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-interactive
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-interactive
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Switch](https://suiss.app/ui/docs/components/switch), [Toggle Group](https://suiss.app/ui/docs/components/toggle-group).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-interactive.tsx"
"use client"

import * as React from "react"
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts"

import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"
import { Switch } from "@/components/ui/switch"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

type Indicator = "dot" | "line" | "dashed"

type Trigger = "hover" | "click"

const chartData = [
  ["Q1 25", 69.1, 9, 26.3],
  ["Q2 25", 46.8, 8, 26.6],
  ["Q3 25", 44.6, 8, 27.4],
  ["Q4 25", 46.2, 8.7, 28.8],
  ["Q1 26", 71, 9.5, 29.1],
  ["Q2 26", 49.4, 8.6, 29.4],
  ["Q3 26", 47.3, 8.9, 30.1],
  ["Q4 26", 49, 9.3, 31.2],
].map(([quarter, phones, laptops, services]) => ({
  quarter: quarter as string,
  phones: phones as number,
  laptops: laptops as number,
  services: services as number,
}))

const chartConfig = {
  phones: { label: "Phones", color: "var(--chart-1)" },
  laptops: { label: "Laptops", color: "var(--chart-2)" },
  services: { label: "Services", color: "var(--color-purple-500)" },
} satisfies ChartConfig

const INDICATORS: Record<Indicator, string> = {
  dot: "Dot",
  line: "Line",
  dashed: "Dashed",
}

const TRIGGERS: Record<Trigger, string> = {
  hover: "On hover",
  click: "On click",
}

const billions = new Intl.NumberFormat("en-US", {
  minimumFractionDigits: 1,
  maximumFractionDigits: 1,
})

function Setting({
  label,
  checked,
  onCheckedChange,
}: {
  label: string
  checked: boolean
  onCheckedChange: (checked: boolean) => void
}) {
  const id = React.useId()

  return (
    <div className="flex items-center gap-2.5 text-sm">
      <Switch id={id} checked={checked} onCheckedChange={onCheckedChange} />
      <label htmlFor={id}>{label}</label>
    </div>
  )
}

export function TooltipChartInteractive() {
  const [indicator, setIndicator] = React.useState<Indicator>("dot")
  const [trigger, setTrigger] = React.useState<Trigger>("hover")
  const [showTotal, setShowTotal] = React.useState(true)
  const [hideLabel, setHideLabel] = React.useState(false)
  const [hideIndicator, setHideIndicator] = React.useState(false)

  return (
    <Card variant="filled" size="sm" className="[--card-spacing:--spacing(5)]">
      <CardHeader className="gap-0.5">
        <p className="text-lg font-semibold">Tooltip settings</p>
        <p className="text-sm text-muted-foreground">
          Quarterly revenue · billions · sample data. Change the settings and
          point at the bars.
        </p>
      </CardHeader>
      <CardContent className="flex flex-col gap-5">
        <div className="flex flex-wrap items-end gap-x-6 gap-y-3">
          <div className="flex flex-col gap-1.5">
            <span className="text-xs font-semibold text-muted-foreground">
              Indicator
            </span>
            <ToggleGroup
              spacing={0}
              value={[indicator]}
              onValueChange={(value: string[]) => {
                if (value[0]) setIndicator(value[0] as Indicator)
              }}
              aria-label="Indicator"
            >
              {(Object.keys(INDICATORS) as Indicator[]).map((key) => (
                <ToggleGroupItem key={key} value={key} size="sm">
                  {INDICATORS[key]}
                </ToggleGroupItem>
              ))}
            </ToggleGroup>
          </div>
          <div className="flex flex-col gap-1.5">
            <span className="text-xs font-semibold text-muted-foreground">
              Trigger
            </span>
            <ToggleGroup
              spacing={0}
              value={[trigger]}
              onValueChange={(value: string[]) => {
                if (value[0]) setTrigger(value[0] as Trigger)
              }}
              aria-label="Trigger"
            >
              {(Object.keys(TRIGGERS) as Trigger[]).map((key) => (
                <ToggleGroupItem key={key} value={key} size="sm">
                  {TRIGGERS[key]}
                </ToggleGroupItem>
              ))}
            </ToggleGroup>
          </div>
          <div className="flex flex-wrap gap-x-5 gap-y-2.5 pb-1">
            <Setting
              label="Total in title"
              checked={showTotal}
              onCheckedChange={setShowTotal}
            />
            <Setting
              label="Hide title"
              checked={hideLabel}
              onCheckedChange={setHideLabel}
            />
            <Setting
              label="Hide indicator"
              checked={hideIndicator}
              onCheckedChange={setHideIndicator}
            />
          </div>
        </div>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-72 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="quarter"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              minTickGap={8}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              tickFormatter={(value: number) => `${value}B`}
            />
            <ChartTooltip
              key={trigger}
              trigger={trigger}
              defaultIndex={4}
              cursor={false}
              content={
                <ChartTooltipContent
                  indicator={indicator}
                  hideLabel={hideLabel}
                  hideIndicator={hideIndicator}
                  labelFormatter={
                    showTotal
                      ? (label, payload) => (
                          <div className="flex justify-between gap-4">
                            <span>{label}</span>
                            <span className="tabular-nums">
                              {billions.format(
                                payload.reduce(
                                  (sum, item) => sum + Number(item.value ?? 0),
                                  0
                                )
                              )}
                              B
                            </span>
                          </div>
                        )
                      : undefined
                  }
                />
              }
            />
            <ChartLegend content={<ChartLegendContent />} />
            <Bar
              dataKey="services"
              stackId="a"
              fill="var(--color-services)"
              radius={[0, 0, 4, 4]}
              maxBarSize={44}
            />
            <Bar
              dataKey="laptops"
              stackId="a"
              fill="var(--color-laptops)"
              maxBarSize={44}
            />
            <Bar
              dataKey="phones"
              stackId="a"
              fill="var(--color-phones)"
              radius={[4, 4, 0, 0]}
              maxBarSize={44}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartInteractive } from "@/components/charts/tooltip-chart-interactive"
```

```tsx
<TooltipChartInteractive />
```



## Tooltip Chart Label Formatter

A gradient area chart whose tooltip heading shows a longer date than the axis ticks.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#label-formatter

**React**

**Example**

```tsx title="components/charts/tooltip-chart-label-formatter.tsx"
"use client"

import * as React from "react"
import { Area, AreaChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

function dayKey(date: Date) {
  return [
    date.getFullYear(),
    String(date.getMonth() + 1).padStart(2, "0"),
    String(date.getDate()).padStart(2, "0"),
  ].join("-")
}

const chartData = [
  512, 604, 455, 389, 662, 598, 431, 520, 690, 447, 575, 402, 633, 558,
].map((energy, index) => ({
  date: dayKey(new Date(2026, 8, 23 + index)),
  energy,
}))

const chartConfig = {
  energy: { label: "Active energy", color: "var(--color-red-500)" },
} satisfies ChartConfig

const longDate = new Intl.DateTimeFormat("en-US", {
  weekday: "long",
  month: "long",
  day: "numeric",
})

export function TooltipChartLabelFormatter() {
  const id = React.useId()
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Custom label</CardTitle>
        <CardDescription>The date written out in full</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <AreaChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 12, left: 12, bottom: 0 }}
          >
            <defs>
              <linearGradient id={id} x1="0" y1="0" x2="0" y2="1">
                <stop
                  offset="0%"
                  stopColor="var(--color-energy)"
                  stopOpacity={0.38}
                />
                <stop
                  offset="100%"
                  stopColor="var(--color-energy)"
                  stopOpacity={0.02}
                />
              </linearGradient>
            </defs>
            <XAxis
              dataKey="date"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={2}
              tickFormatter={(value: string) => String(Number(value.slice(8)))}
            />
            <ChartTooltip
              defaultIndex={8}
              content={
                <ChartTooltipContent
                  indicator="line"
                  labelFormatter={(_, payload) =>
                    longDate.format(
                      new Date(`${payload[0]?.payload.date}T12:00:00`)
                    )
                  }
                />
              }
            />
            <Area
              dataKey="energy"
              type="monotone"
              stroke="var(--color-energy)"
              strokeWidth={2}
              fill={`url(#${id})`}
            />
          </AreaChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

Two weeks of active energy as a gradient area, where the axis shows only day numbers but the tooltip heading spells out the weekday. Use a label formatter when the axis needs short labels and the tooltip has room for the full context.

Pass a `labelFormatter` to `ChartTooltipContent` and build the heading from the hovered record, which arrives in its second argument. The demo format shows the weekday, month and day but no year, so ranges across a month boundary stay clear; add the year if your range spans more than one.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-label-formatter
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-label-formatter
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-label-formatter.tsx"
"use client"

import * as React from "react"
import { Area, AreaChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

function dayKey(date: Date) {
  return [
    date.getFullYear(),
    String(date.getMonth() + 1).padStart(2, "0"),
    String(date.getDate()).padStart(2, "0"),
  ].join("-")
}

const chartData = [
  512, 604, 455, 389, 662, 598, 431, 520, 690, 447, 575, 402, 633, 558,
].map((energy, index) => ({
  date: dayKey(new Date(2026, 8, 23 + index)),
  energy,
}))

const chartConfig = {
  energy: { label: "Active energy", color: "var(--color-red-500)" },
} satisfies ChartConfig

const longDate = new Intl.DateTimeFormat("en-US", {
  weekday: "long",
  month: "long",
  day: "numeric",
})

export function TooltipChartLabelFormatter() {
  const id = React.useId()
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Custom label</CardTitle>
        <CardDescription>The date written out in full</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <AreaChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 12, left: 12, bottom: 0 }}
          >
            <defs>
              <linearGradient id={id} x1="0" y1="0" x2="0" y2="1">
                <stop
                  offset="0%"
                  stopColor="var(--color-energy)"
                  stopOpacity={0.38}
                />
                <stop
                  offset="100%"
                  stopColor="var(--color-energy)"
                  stopOpacity={0.02}
                />
              </linearGradient>
            </defs>
            <XAxis
              dataKey="date"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={2}
              tickFormatter={(value: string) => String(Number(value.slice(8)))}
            />
            <ChartTooltip
              defaultIndex={8}
              content={
                <ChartTooltipContent
                  indicator="line"
                  labelFormatter={(_, payload) =>
                    longDate.format(
                      new Date(`${payload[0]?.payload.date}T12:00:00`)
                    )
                  }
                />
              }
            />
            <Area
              dataKey="energy"
              type="monotone"
              stroke="var(--color-energy)"
              strokeWidth={2}
              fill={`url(#${id})`}
            />
          </AreaChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartLabelFormatter } from "@/components/charts/tooltip-chart-label-formatter"
```

```tsx
<TooltipChartLabelFormatter />
```



## Tooltip Chart Line

A stacked bar chart whose tooltip marks each series with a thin vertical color bar.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#line

**React**

**Example**

```tsx title="components/charts/tooltip-chart-line.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartLine() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Line indicator</CardTitle>
        <CardDescription>indicator=&quot;line&quot;</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent indicator="line" />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A stacked bar chart that shows the line tooltip indicator, a thin vertical bar in each series' color. It reads cleanly in dense tooltips and pairs well with line and area charts.

Set `indicator` on `ChartTooltipContent` to `line`. Replace `chartData` and the series in `chartConfig` with your own. The tooltip opens on a preset month when the chart loads; remove `defaultIndex` if it should start hidden.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-line
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-line
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-line.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartLine() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Line indicator</CardTitle>
        <CardDescription>indicator=&quot;line&quot;</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent indicator="line" />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartLine } from "@/components/charts/tooltip-chart-line"
```

```tsx
<TooltipChartLine />
```



## Tooltip Chart No Indicator

A stacked bar chart whose tooltip lists series names and values without color indicators.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#no-indicator

**React**

**Example**

```tsx title="components/charts/tooltip-chart-no-indicator.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartNoIndicator() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>No indicator</CardTitle>
        <CardDescription>Just the name and value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent hideIndicator />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A stacked bar chart whose tooltip lists series names and values without any color marker. Use it for single-series charts, or when the series names are clear enough on their own.

Set `hideIndicator` on `ChartTooltipContent`, and keep the series labels descriptive since they are the only cue. Without a color marker readers can't match a row to a bar, so this suits one or two clearly named series.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-no-indicator
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-no-indicator
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-no-indicator.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartNoIndicator() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>No indicator</CardTitle>
        <CardDescription>Just the name and value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent hideIndicator />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartNoIndicator } from "@/components/charts/tooltip-chart-no-indicator"
```

```tsx
<TooltipChartNoIndicator />
```



## Tooltip Chart No Label

A stacked bar chart whose tooltip omits the category heading and shows only the series rows.

Source: https://suiss.app/ui/docs/charts/tooltip-chart#no-label

**React**

**Example**

```tsx title="components/charts/tooltip-chart-no-label.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartNoLabel() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>No label</CardTitle>
        <CardDescription>The month is hidden</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent hideLabel />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A stacked bar chart whose tooltip drops the category heading and shows only the series rows. Use it when the hovered category is obvious from the axis and you want a smaller tooltip.

Set `hideLabel` on `ChartTooltipContent`. Replace `chartData` and the series in `chartConfig` with your own. The tooltip opens on a preset month when the chart loads; remove `defaultIndex` if it should start hidden.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/tooltip-chart-no-label
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts tooltip-chart-no-label
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/tooltip-chart-no-label.tsx"
"use client"

import { Bar, BarChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function TooltipChartNoLabel() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>No label</CardTitle>
        <CardDescription>The month is hidden</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-52 w-full"
        >
          <BarChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={2}
              cursor={false}
              content={<ChartTooltipContent hideLabel />}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              fill="var(--color-desktop)"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              fill="var(--color-mobile)"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { TooltipChartNoLabel } from "@/components/charts/tooltip-chart-no-label"
```

```tsx
<TooltipChartNoLabel />
```

