Skip to content

TkxSparkline

TkxSparkline is a compact, inline trend chart for tables, cards, and stat rows — no axes, just the shape of a series. It renders inside a <span> so it flows with text. Three variants are available: line, area, and bar.

import { TkxSparkline } from 'tekivex-ui';
<TkxSparkline data={[3, 7, 4, 9, 6, 12, 8]} showValue />
PropTypeDefaultDescription
datanumber[]The series to plot (required).
variant'line' | 'area' | 'bar''line'Render style.
widthnumber120SVG width in px.
heightnumber32SVG height in px.
colorstringtheme.primaryStroke / fill colour.
showPointsbooleanfalseDraw a dot at every data point (line/area only).
showLastPointbooleantrueDraw a dot at the final point (suppressed when showPoints is on).
showValuebooleanfalseRender the last value as text beside the chart.
smoothbooleanfalseUse a Catmull-Rom smoothed curve instead of straight segments (line/area only).
ariaLabelstringautoAccessible name; auto-describes count and trend.

All other span attributes are spread onto the root.

  • The auto-generated aria-label describes the trend direction (up / down / flat) by comparing the first and last value, e.g. “Sparkline showing 7 values, trending up”. Override it via ariaLabel.
  • showLastPoint is ignored when showPoints is true (the full set of points already includes the last one).
  • smooth only affects line and area — the bar variant ignores it.
  • A single-value series renders centred; an empty array renders an empty SVG with an accessible “no data” label.
  • The inner SVG is aria-hidden; the accessible description lives on the root span with role="img".

src/components/TkxSparkline.tsx