GitHub

Sparkline

Inline SVG mini-charts for line, area, and bar visualization.

<rhx-sparkline>

Examples

Line (Default)

Default line sparkline with currentColor stroke

Custom stroke color and width

Custom size: 300px wide, 3rem tall

Area

Area with auto fill (stroke color at 20% opacity)

Area with custom fill color

Bar

Bar chart with custom fill

Bar chart with default fill (uses stroke color)

Min/Max Override

Fixed Y-axis range: 0 to 100

Negative values with area fill

Inline Usage

CPU usage 72%

Revenue $280k

Scores avg 7.5

Properties

Property Type Default Description
rhx-values double[] - Array of numeric data points to plot
rhx-type string line Chart type: line, area, bar
rhx-min double? auto Minimum Y-axis value (auto-calculated from data if omitted)
rhx-max double? auto Maximum Y-axis value (auto-calculated from data if omitted)
rhx-width string 100% SVG width as CSS value
rhx-height string 2rem SVG height as CSS value
rhx-stroke-width double 2 Line stroke width in pixels
rhx-stroke-color string currentColor Stroke color (any CSS color value)
rhx-fill-color string? - Fill color for area/bar types (area defaults to stroke at 20% opacity)
rhx-label string? - Accessible label; sets role="img" and aria-label. If omitted, aria-hidden="true"

Accessibility

  • When rhx-label is set, the SVG receives role="img" and aria-label with the provided text.
  • When no label is provided, the SVG is marked aria-hidden="true" so screen readers skip the decorative chart.
  • Sparklines are inline elements that flow naturally with surrounding text content.
  • Color is not the sole means of conveying information — pair sparklines with numeric values or labels for context.