Interactive example
Saved items trendSynthetic saved item counts
Use arrow keys to select a data point. Home selects the first point and End selects the last. Escape closes the value tooltip.
Mon
Value
18
View data table 7 rows
Saved items trend
Data pointValue
Mon18
Tue21
Wed19
Thu27
Fri25
Sat31
Sun29

Installation

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

const data = [
  { label: "Mon", value: 18 },
  { label: "Tue", value: 21 },
  { label: "Wed", value: 19 },
  { label: "Thu", value: 27 },
  { label: "Fri", value: 25 },
  { label: "Sat", value: 31 },
];

export function Example() {
  return (
    <Sparkline
      title="Saved items trend"
      description="Synthetic saved item counts"
      data={data}
      height={80}
    />
  );
}

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
valueKeystringvalue
labelKeystringlabel
colorstringsystem blue
heightnumber80
titlestringrequired
descriptionstringundefined
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 sparkline beside a clearly labeled current value or summary.
  • Do not use it as the only source for exact values. Keep the table disclosure available when the series matters.
  • Use a line chart when axes, comparison series, or precise intervals are part of the question.
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.