Sparkline

A minimal inline chart for showing trends at a glance. Perfect for dashboards, tables, and anywhere you need to visualize data trends in a compact space.

Playground

Experiment with different props to see how the Sparkline component behaves. Use the theme switcher in the header to see it adapt to different themes.

Props

Midnight
200
48
OffOn
OffOn
1.5
Code
<Sparkline
  data={data}
  theme="midnight"
  width={200}
  height={48}
  strokeWidth={1.5}
/>

Usage

Import the component and pass your data. The chart automatically fills its container width:

tsx
import { Sparkline } from '@derpdaderp/chartkit';

const data = [
  { value: 10 },
  { value: 25 },
  { value: 15 },
  { value: 30 },
  { value: 22 },
];

// Responsive - fills container width automatically
<Sparkline data={data} theme="midnight" />

// Fixed width
<Sparkline data={data} theme="midnight" width={120} height={32} />

With Plain Numbers

You can also pass an array of plain numbers:

tsx
<Sparkline
  data={[10, 25, 15, 30, 22, 28, 35]}
  theme="midnight"
/>

With Glow Effect

Add a glow effect for a more dramatic visualization:

tsx
<Sparkline
  data={data}
  theme="midnight"
  glow
/>

With Area Fill

Fill the area under the line for a more substantial look:

tsx
<Sparkline
  data={data}
  theme="midnight"
  fill
/>

Custom Color

Override the default theme color:

tsx
<Sparkline
  data={data}
  theme="midnight"
  color="#f472b6"
/>

Props

PropTypeDefaultDescription
data*T[] | number[]-Data array - can be objects or plain numbers
dataKeykeyof T"value"Key to extract numeric value when data contains objects
widthnumberautoChart width in pixels (auto-fills container if not set)
heightnumber32Chart height in pixels
theme*ThemeName-Theme name
colorstring-Override line color
glowbooleanfalseEnable glow effect on line
fillbooleanfalseFill area under the line
strokeWidthnumber1.5Line stroke width
classNamestring-Additional CSS class