Sparkline
Show a compact trend beside a value.
npx shadcn@latest add @silicon-ui/sparklineInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/sparklineManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/sparkline/sparkline.tsx
- components/silicon-ui/sparkline/sparkline.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
data* | number[] | — |
label* | string | — |
value | string | — |
change | string | — |
tone | "accent" | "success" | "warning" | "danger" | "accent" |
width | number | 160 |
height | number | 52 |
labelsOne label per point, such as a date. It replaces the change while that point is scrubbed. | string[] | — |
formatValueFormats a scrubbed point for the headline. Defaults to a grouped number. | (value: number, index: number) => string | — |
areaA quiet neutral fill under the line. | boolean | true |
interactivePointer and keyboard scrubbing through the points. | boolean | true |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokens