Import
tsx
import { Sparkline } from "@indoku/ui"Examples
Basic
tsx
const up = [10, 12, 11, 15, 14, 18, 17, 21]const down = [21, 19, 20, 16, 17, 13, 12, 9]const stocks = [ { name: "AAPL", price: "$231.4", values: [10, 12, 11, 15, 14, 18, 17, 21] }, { name: "TSLA", price: "$412.9", values: [21, 19, 20, 16, 17, 13, 12, 9] }, { name: "NVDA", price: "$188.2", values: [8, 9, 12, 11, 15, 14, 19, 22] },]function SparkBasic() { return <Sparkline values={up} />}Area
tsx
const up = [10, 12, 11, 15, 14, 18, 17, 21]const down = [21, 19, 20, 16, 17, 13, 12, 9]const stocks = [ { name: "AAPL", price: "$231.4", values: [10, 12, 11, 15, 14, 18, 17, 21] }, { name: "TSLA", price: "$412.9", values: [21, 19, 20, 16, 17, 13, 12, 9] }, { name: "NVDA", price: "$188.2", values: [8, 9, 12, 11, 15, 14, 19, 22] },]function SparkArea() { return <Sparkline values={up} area width={200} height={48} />}Trend color
color=trend is green when the series ends higher, red when lower.
tsx
Interaction tooltip
Hover to read a value.
tsx
function SparkInteractive() { return <Sparkline values={[4, 7, 5, 9, 12, 8, 14, 11, 16]} width={260} height={64} interactive area />}Stock composition
Sparklines inside a watchlist.
AAPL
$231.4
TSLA
$412.9
NVDA
$188.2
tsx
Props
Sparkline
| Prop | Type | Default | Description |
|---|---|---|---|
values | number[] | – | Data points. |
color | string | 'blue' | Color token, or trend. |
area | boolean | false | Fill under the line. |
interactive | boolean | false | Show the hovered value. |
width / height | number | 120 / 32 | Size in px. |
* required. Style props and HTML attributes are accepted as well.
Created by @indokudev