Interactive example
Hours by work modeSynthetic daily hours
  • Focused work
  • Routine work
Use arrow keys to select a data point. Home selects the first point and End selects the last. Escape closes the value tooltip.
Mon
Focused work
3.8 h
Routine work
2.1 h
View data table 6 rows
Hours by work mode
Data pointFocused workRoutine work
Mon3.8 h2.1 h
Tue4.6 h2.4 h
Wed5.1 h2.7 h
Thu4.4 h2.6 h
Fri5.7 h3.2 h
Sat3.1 h1.8 h

Installation

terminal
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/area-chart.json

The registry includes the shared styles and dependencies. Import @/components/apple-ui/styles.css in your root layout once. For the package route, use the installation guide.

Usage

tsx
"use client";

import { AreaChart } from "@eduardoul/apple-ui";

const data = [
  { label: "Mon", focused: 3.8, routine: 2.1 },
  { label: "Tue", focused: 4.6, routine: 2.4 },
  { label: "Wed", focused: 5.1, routine: 2.7 },
  { label: "Thu", focused: 4.4, routine: 2.6 },
  { label: "Fri", focused: 5.7, routine: 3.2 },
];

export function Example() {
  return (
    <AreaChart
      title="Hours by work mode"
      description="Synthetic daily hours"
      data={data}
      series={[
        { key: "focused", label: "Focused work" },
        { key: "routine", label: "Routine work" },
      ]}
      valueFormatter={(value) => value.toFixed(1) + " h"}
    />
  );
}

Package imports use @eduardoul/apple-ui. Registry imports use @/components/apple-ui. Add "use client" to files that use state or event handlers.

API reference

PropertyTypeDefault
dataChartDatum[]required
seriesChartSeries[]required
labelKeystringlabel
titlestringrequired
descriptionstringundefined
heightnumbercomponent default
loadingbooleanfalse
errorstringundefined
emptyMessagestringNo data to display.
showTablebooleantrue
compactbooleanfalse
valueFormatter(value: number) => stringlocalized number
classNamestringundefined
styleReact.CSSPropertiesundefined

Use className and style to customize the component. The package includes full TypeScript definitions for its supported element properties and refs.

Design guidance

  • Use one or two series when magnitude matters as much as direction.
  • Start the vertical scale at zero when readers need to compare the filled area itself.
  • Prefer a line chart when overlapping fills obscure the data or when precise comparison matters more than volume.
Read Apple’s guidance

Accessibility

Give the chart a descriptive title and explain its units. Select a data point to read its values, or open the data table for the full dataset. Labels and values accompany color, and the chart adapts to reduced motion and appearance preferences. Test long labels, touch input and keyboard navigation with your own data.

Library styles support reduced motion, reduced transparency, increased contrast and forced colors. Read the accessibility foundation for the checks your application still needs.