Interactive example
Monthly active projectsMonthly project counts. Studio has no March observation. Synthetic example data.
  • Studio
  • Field
Use arrow keys to select a data point. Home selects the first point and End selects the last. Escape closes the value tooltip.
Jan
Studio
42
Field
31
View data table 6 rows
Monthly active projects
Data pointStudioField
Jan4231
Feb4835
MarNo data39
Apr5744
May6449
Jun6955

Installation

terminal
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/line-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 { LineChart } from "@eduardoul/apple-ui";

const data = [
  { label: "Jan", studio: 42, field: 31 },
  { label: "Feb", studio: 48, field: 35 },
  { label: "Mar", studio: null, field: 39 },
  { label: "Apr", studio: 57, field: 44 },
  { label: "May", studio: 64, field: 49 },
];

export function Example() {
  return (
    <LineChart
      title="Monthly active projects"
      description="Monthly project counts. Studio has no March observation. Synthetic example data."
      data={data}
      series={[
        { key: "studio", label: "Studio" },
        { key: "field", label: "Field" },
      ]}
      valueFormatter={(value) => value.toLocaleString()}
    />
  );
}

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 a line when the order of values matters, usually across time.
  • Keep missing observations as gaps. A connected line can imply that a value was measured when it was not.
  • Limit the number of series when their paths overlap. Direct labels or a short legend should make each line easy to identify.
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.