Loading...
Loading...
> Compact line charts for showing trends and data patterns inline with text or in small spaces.
1import { Sparkline, SparklineCard, SparklineGroup } from "@/components/ui/sparkline";
1<Sparkline2 data={[4, 8, 5, 10, 7, 12, 8, 15, 11, 14]}3 width={100}4 height={30}5 strokeWidth={2}6/>
1<Sparkline2 data={sampleData}3 width={100}4 height={40}5 showArea={true}6/>7<Sparkline8 data={revenueData}9 width={100}10 height={40}11 showArea={true}12 color="oklch(70% 0.15 160)"13/>
1<Sparkline2 data={sampleData}3 width={120}4 height={40}5 showDots={true}6/>7<Sparkline8 data={revenueData}9 width={120}10 height={40}11 showDots={true}12 showArea={true}13/>
Revenue
$12,345
+12.5% vs last month
Active Users
2,847
-5.2% vs last week
1<SparklineCard2 title="Revenue"3 value="$12,345"4 change={{ value: 12.5, label: "vs last month" }}5 data={revenueData}6 sparklineColor="oklch(70% 0.15 160)"7/>8<SparklineCard9 title="Active Users"10 value="2,847"11 change={{ value: -5.2, label: "vs last week" }}12 data={usersData}13 sparklineColor="oklch(70% 0.15 295)"14/>
Page Views
12345
Sessions
8234
Bounce Rate
42.3
1<SparklineGroup2 items={[3 {4 label: "Page Views",5 value: 12345,6 data: [100, 120, 115, 140, 130, 150, 145, 160],7 color: "oklch(70% 0.15 220)",8 },9 {10 label: "Sessions",11 value: 8234,12 data: [80, 85, 90, 95, 88, 100, 105, 110],13 color: "oklch(70% 0.15 160)",14 },15 ]}16/>
1<Sparkline2 data={sampleData}3 width={100}4 height={40}5 showArea={true}6 color="oklch(60% 0.20 25)"7 fillColor="oklch(60% 0.20 25)"8/>
| Prop | Type | Default | Description |
|---|---|---|---|
| data* | number[] | - | Array of numeric values to plot |
| width | number | 100 | Width of the sparkline in pixels |
| height | number | 30 | Height of the sparkline in pixels |
| strokeWidth | number | 2 | Width of the line stroke |
| color | string | "var(--color-primary)" | Color of the line |
| fillColor | string | - | Color of the area fill (defaults to color) |
| showArea | boolean | false | Show filled area below line |
| showDots | boolean | false | Show dots at data points |
| className | string | - | Additional CSS classes |