Controls

Capsule Stack Chart

Effect
Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Capsule Stack Chart
  • Focus
  • Meetings

Share of the workday
dayFocusMeetings
27 Jun32%40%
28 Jun25%38%
29 Jun34%41%
30 Jun37%30%
1 Jul37%50%
2 Jul46%22%
3 Jul25%50%

Capsule Stack Chart

Soft capsules stacked in each column, with a hatched cap for what is left of the whole.

Installation

npx shadcn@latest add ikislay/pixel-ui/capsule-stack-chart

How to use

import { CapsuleStackChart } from "@/components/ui/capsule-stack-chart"
const data = [
{ day: "27 Jun", focus: 32, meetings: 40 },
{ day: "28 Jun", focus: 25, meetings: 38 },
{ day: "29 Jun", focus: 34, meetings: 41 },
]
export function Demo() {
return (
<CapsuleStackChart
label="Share of the workday"
data={data}
index="day"
series={[

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
data*
Record<string, string | number>[]

One object per point along the x axis.

index*
string

The key in each object that labels the x axis.

series*
{ key: string; label?: string; color?: string }[]

The keys to plot. Colors follow the chart palette in order unless you set one.

label*
string

Names the chart for screen readers and captions its data table.

height
number

Height in pixels. The width fills the parent.

format
(value: number) => string

Formats each value in its pill and the table. Defaults to whole percents.

max
number

The amount a full column stands for. The hatched cap fills the gap between a column's sum and this.

className
string

Merged onto the root element.