Playground

Line chart

Show how one or more values change across an ordered axis, with straight or stepped lines.

  • Built on native elements
  • The chart is role=img with the required title as its name.
  • A visually hidden table lists every value, one row per category, for screen readers.
  • One focusable stop per category with a spoken label; Arrow keys move between them and Escape hides the tooltip.
  • Styles in one file: chart.css

Import

import '@monoline/css';
import {LineChart} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add line-chart

Usage

import {LineChart} from '@monoline/react';

<LineChart
  title="Response time"
  showPoints
  data={[{label: 'Mon', value: 120}, {label: 'Tue', value: 98}, {label: 'Wed', value: 143}, {label: 'Thu', value: 110}, {label: 'Fri', value: 87}]}
/>

Examples

Single series with points

Multiple series

Series differ by dash pattern and marker shape as well as colour.

Stepped

Single point and empty

Props

LineChartProps

PropTypeDefaultDescription
showPointsboolean–Mark each data point. A single point is always marked.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[data-active]chart.css
[data-align="end"]chart.css
[data-align="start"]chart.css

CSS classes

ClassStylesheet
.chartchart.css
.chart-areachart.css
.chart-emptychart.css
.chart-hitchart.css
.chart-hitschart.css
.chart-legendchart.css
.chart-legend-detailchart.css
.chart-linechart.css
.chart-markschart.css
.chart-outlinechart.css
.chart-patchart.css
.chart-pat-dotchart.css
.chart-plotchart.css
.chart-rulechart.css
.chart-s0chart.css
.chart-s1chart.css
.chart-s2chart.css
.chart-s3chart.css
.chart-s4chart.css
.chart-svgchart.css
.chart-swatchchart.css
.chart-tickchart.css
.chart-tipchart.css
.chart-tip-rowchart.css
.chart-tip-titlechart.css
.chart-tip-valuechart.css
.chart-valuechart.css
.chart-zerochart.css
.chart-guideline-chart.css
.chart-pointline-chart.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.chart {
  border-color: var(--accent);
}
.chart[data-active] {
  background: var(--wash);
}

Accessibility

  • The chart is role=img with the required title as its name.
  • A visually hidden table lists every value, one row per category, for screen readers.
  • One focusable stop per category with a spoken label; Arrow keys move between them and Escape hides the tooltip.
  • The value tooltip opens on hover and on keyboard focus.
  • Series differ by dash pattern and marker shape as well as colour, and the legend names them.
  • No entrance animation under prefers-reduced-motion.

Keyboard

KeysAction
Arrow keysMove between them and Escape hides the tooltip