Appica UIUI 1.6.0

Charts

Chart recipes - Recharts 3 drawn with Appica UI tokens, with a tooltip, a legend and motion that match the components.

Charts in Appica UI are recipes. Recharts draws the chart, and 1 file you copy into your project, the chart layer, gives it the library's colors, tooltip, legend and motion. You still write AreaChart, Bar and XAxis yourself, so every Recharts prop still works.

This page sets up the chart layer and explains its parts. Each chart type has its own page of examples to copy: Area, Line, Bar, Pie, Radial, Radar, Scatter, Funnel, Sankey, Treemap and Heatmap. A small trend in a tile or a table row is a Sparkline and a quota is a Meter. Neither needs Recharts.

Installation

Recharts 3.11 or later is the only extra dependency. It needs react-is at the same version as react, so install both:

pnpm add recharts react-is

Then save the chart layer as components/chart.tsx. Every example imports it as @/components/chart.

The chart layer

The layer is this 1 file. It imports recharts and Appica UI, and nothing else from your project.

components/chart.tsx

A chart built with it looks like this:

Chart

The frame around a Recharts chart. It provides the theme (colors, type, grid, cursor), sizes the chart to itself, and keeps the plot left-to-right. The chart inside takes responsive, and no width, height or ResponsiveContainer. Renders a <div> and forwards its remaining props to it.

ChartTooltip

The content of a Recharts Tooltip. Pass it as an element, with its own props on it, and Recharts supplies the active point:

ChartLegend

The content of a Recharts Legend. It takes no props of its own:

itemSorter={null} keeps the items in the order of the series, where Recharts would sort them by name. Give the Legend an onClick and every item becomes a toggle button, as in the interactive line chart.

useChartMotion

A hook that returns the animation props of a series. They reveal the series once on mount, morph it when the data changes, and turn animation off under reduced motion.

Constants

Examples

In a card

A chart usually sits in a Card, under a value and a period control. The card has the heading, so the chart needs none. Pick another period: the area morphs to the new data and the reveal does not play again.

Loading

Loading and empty states

A chart keeps its height in every state, so the layout around it doesn't jump. While the data loads, show a Skeleton of the chart's height. With no rows, keep the frame and say there is no data.

Loading

Colors

A series takes its color from chartColors: the library's --chart-1 to --chart-5 tokens, 5 accent families in a fixed order. Each one is the -strong step of its family in light mode and the fuller -emphasis step in dark mode. They point at the family tokens, so a theme that recolors secondary recolors series 1 with it. Recharts writes the var() strings into the DOM as they are, and .dark switches a chart with no render.

Loading
  • The order is fixed. It keeps neighboring colors apart for color-blind readers, so take the slots in order and never skip or cycle them. Orange never ends up beside red this way, nor blue beside sky: those are the 2 pairs that are hardest to tell apart.
  • Use 5 series at most. Group a sixth as "Other" in var(--foreground-subtle). On a scatter chart, where any 2 points can touch, use the first 3 slots only.
  • A single series takes slot 1. A comparison period is the same color, dashed, at 60% stroke opacity. A neutral series, such as a target or a baseline, is var(--foreground-subtle).
  • When the data is a status, meaning comes before order: succeeded is the success color (chartColors[1]), pending the warning color (chartColors[2]) and failed the error color (chartColors[4]).
  • Tints are the translucent steps of the same family, and they are the same in both modes: -soft (20%) for the top of an area fill, a band or a bubble, and -subtle (10%) for a bar's track or a hover wash. An area fill is a vertical gradient from -soft to transparent.
  • Text never takes a series color. Ticks, legend labels and values use the foreground tokens, and the swatch beside them carries the identity. None of the 5 light-mode colors reaches 3:1 contrast on white, so every chart with 2 or more series has a legend, and every chart has a tooltip.

Always pass the color to the series as stroke or fill. Without one, the theme assigns colors by the sorted names of the dataKeys, not by the order you wrote the series in.

Where the library defines the tokens, the same colors work outside a chart as var(--chart-1) or bg-chart-1. On a version of the library without them, Chart supplies the same values inside its frame.

Tooltip

Variants

variant picks the surface. solid is Sparkline's tooltip, a bordered card with a shadow. glass is the same card made translucent, with a backdrop blur and a hairline border, in the surface color of the current mode. inverse is the surface of the library's Tooltip. All 3 live in 1 map of classes in the chart layer. If you only want 1 look, delete the other 2 entries.

Loading

These 3 tooltips are pinned open with defaultIndex and active on the Recharts Tooltip. The same 2 props mark a point before anyone touches the chart.

Indicators

indicator sets the swatch beside each name: a dot, a line or a dashed line. hideIndicator removes it and hideLabel removes the heading.

Loading

Motion

All chart motion is timed in the chart layer. useChartMotion passes the series timings to Recharts, and the frame handles the rest with Tailwind classes.

None of it runs under reduced motion. Recharts follows the OS setting on its own, and useChartMotion also reads useReducedMotion, so a ReducedMotionProvider turns charts off with everything else.

Server Components

Recharts draws in the browser. On the server a chart is only an empty box of its size. So make the chart a Client Component that takes its data as props, and read the data in the Server Component around it, inside Suspense, with a fallback of the chart's height.

The frame gets its height from a class (h-64 by default) and never from the chart. That is why the box is the same size before and after the chart draws.

RTL

A chart is not mirrored in a right-to-left layout. Time and numbers still run left to right there, so the plot keeps its direction, which is also what Material's bidirectionality guidance recommends. Chart sets dir="ltr" on its frame, which also keeps the tick labels in place, and ChartTooltip and ChartLegend read the direction from DirectionProvider, so their text follows the page.

Add no rtl: variant and no reversed axis. Format numbers and dates with Intl and the page's locale, as the examples do.

Accessibility

  • Give every chart an aria-label that says what it shows. Recharts passes it to the SVG as its accessible name. Its own title prop names the chart too, but browsers also show it as a native tooltip beside yours.
  • A chart takes keyboard focus, and the arrow keys move the tooltip from point to point. This is Recharts' accessibilityLayer, on by default: leave it on.
  • Color is never the only cue. A chart with 2 or more series has a legend, every chart has a tooltip that names each series, and text keeps the foreground tokens.
  • A legend item that toggles a series is a real <button> with aria-pressed.
  • Charts honor reduced motion, from the OS setting and from ReducedMotionProvider.
  • A chart shows the shape of the data. When readers need the exact numbers, put them in a Table beside it.

© 2026 Appica UI. A free component library, crafted by the Appica team.