Controls

Waffle Chart

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.

Waffle Chart
Subscriptions this year
  • Renewed6262%
  • Upgraded1414%
  • Paused77%

Waffle Chart

A grid of soft squares where each square stands for an equal share.

Installation

npx shadcn@latest add ikislay/pixel-ui/waffle-chart

How to use

import { WaffleChart } from "@/components/ui/waffle-chart"
const data = [
{ label: "Renewed", value: 62 },
{ label: "Upgraded", value: 14 },
]
export function Demo() {
return <WaffleChart label="Subscriptions this year" data={data} total={100} />
}

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
data*
{ label: string; value: number; color?: string }[]

One part per entry, filled in order. Squares are rounded so the parts always fill the grid exactly.

label*
string

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

total
number

The amount the whole grid stands for. Above the sum of the parts, the rest of the grid stays empty.

columns
number

Squares per row.

rows
number

Rows of squares.

format
(value: number) => string

Formats values wherever the chart shows them. Defaults to short numbers like 12.4K.

className
string

Merged onto the root element.