suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
GitHubGet started
DocsComponentsPatternsInteractionsChartsBlocks
Charts70
  • Overview
Area
  • Axes
  • Default
  • Gradient
  • Interactive
  • Linear
  • Range
  • Sparkline
  • Stacked
  • Stacked Expand
  • Step
Bar
  • Active
  • Default
  • Horizontal
  • Hourly
  • Interactive
  • Labeled
  • Multiple
  • Negative
  • Range
  • Stacked
Line
  • Default
  • Dots
  • Forecast
  • Goal
  • Goal Dots
  • Interactive
  • Labeled
  • Linear
  • Multiple
  • Step
Pie
  • Active
  • Default
  • Donut
  • Donut Text
  • Half
  • Interactive
  • Label
  • Legend
  • Nested
  • Separated
Radar
  • Default
  • Dots
  • Grid Circle
  • Grid Filled
  • Grid None
  • Interactive
  • Legend
  • Lines Only
  • Multiple
  • Radius Axis
Radial
  • Batteries
  • Default
  • Gauge
  • Interactive
  • Label
  • Progress
  • Rings
  • Stacked
  • Text
  • Tinted
Tooltip
  • Custom
  • Dashed
  • Dot
  • Formatter
  • Icons
  • Interactive
  • Label Formatter
  • Line
  • No Indicator
  • No Label

suiss/ui · Chart

Tooltip Chart Icons

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

Tooltip Chart Icons 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.

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.

Installation

CLI

$ 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

Manual

  1. Install the dependencies:
$ pnpm add @phosphor-icons/react recharts
  1. Add the pieces it builds on: Card, Chart.

  2. Copy the source into components/charts/tooltip-chart-icons.tsx:

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,
  1. Update the import paths to match your project.

Usage

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

Add an icon component to each series entry in chartConfig; the tooltip picks it up automatically. Replace chartData and the series keys to match your data.

Notes

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.

NextTooltip Chart InteractivePreviousTooltip Chart Formatter

On this page

  1. 01Installation
    • CLI
    • Manual
  2. 02Usage
  3. 03Notes