suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Charts70
  • Overview
  • Area Chart
  • Bar Chart
  • Line Chart
  • Pie Chart
  • Radar Chart
  • Radial Chart
  • Tooltip Chart

suiss/ui ยท Chart

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.

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 component, used inside charts built on Card.

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

Dot

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

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,

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-dot

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-dot
  1. Install the following dependencies:
$ pnpm add recharts
  1. Add the pieces it builds on: Card, Chart.

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

components/charts/tooltip-chart-dot.tsx
  1. Update the import paths to match your project setup.

Usage

import { TooltipChartDot } from "@/components/charts/tooltip-chart-dot"
<TooltipChartDot />

Custom

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

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"

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-custom

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-custom

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartCustom } from "@/components/charts/tooltip-chart-custom"
<TooltipChartCustom />

Dashed

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

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,

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-dashed

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-dashed

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartDashed } from "@/components/charts/tooltip-chart-dashed"
<TooltipChartDashed />

Formatter

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

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,

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-formatter

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-formatter

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartFormatter } from "@/components/charts/tooltip-chart-formatter"
<TooltipChartFormatter />

Icons

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

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,

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-icons

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-icons

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartIcons } from "@/components/charts/tooltip-chart-icons"
<TooltipChartIcons />

Interactive

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

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"

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-interactive

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-interactive

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartInteractive } from "@/components/charts/tooltip-chart-interactive"
<TooltipChartInteractive />

Label Formatter

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

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,

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-label-formatter

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-label-formatter

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartLabelFormatter } from "@/components/charts/tooltip-chart-label-formatter"
<TooltipChartLabelFormatter />

Line

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

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,

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-line

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-line

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartLine } from "@/components/charts/tooltip-chart-line"
<TooltipChartLine />

No Indicator

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

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,

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-no-indicator

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-no-indicator

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartNoIndicator } from "@/components/charts/tooltip-chart-no-indicator"
<TooltipChartNoIndicator />

No Label

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

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,

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

$ pnpm dlx shadcn@latest add @esuiss/tooltip-chart-no-label

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts tooltip-chart-no-label

Follow the manual steps under Dot and copy this variant's source instead.

Usage

import { TooltipChartNoLabel } from "@/components/charts/tooltip-chart-no-label"
<TooltipChartNoLabel />
NextBlocksPreviousRadial Chart

On this page

  1. 01Dot
  2. 02Custom
  3. 03Dashed
  4. 04Formatter
  5. 05Icons
  6. 06Interactive
  7. 07Label Formatter
  8. 08Line
  9. 09No Indicator
  10. 10No Label