Line chart
Show how one or more values change across an ordered axis, with straight or stepped lines.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- 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
Stepped
Single point and empty
Props
LineChartProps
| Prop | Type | Default | Description |
|---|---|---|---|
showPoints | boolean | – | 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.
| Attribute | Stylesheet |
|---|---|
[data-active] | chart.css |
[data-align="end"] | chart.css |
[data-align="start"] | chart.css |
CSS classes
| Class | Stylesheet |
|---|---|
.chart | chart.css |
.chart-area | chart.css |
.chart-empty | chart.css |
.chart-hit | chart.css |
.chart-hits | chart.css |
.chart-legend | chart.css |
.chart-legend-detail | chart.css |
.chart-line | chart.css |
.chart-marks | chart.css |
.chart-outline | chart.css |
.chart-pat | chart.css |
.chart-pat-dot | chart.css |
.chart-plot | chart.css |
.chart-rule | chart.css |
.chart-s0 | chart.css |
.chart-s1 | chart.css |
.chart-s2 | chart.css |
.chart-s3 | chart.css |
.chart-s4 | chart.css |
.chart-svg | chart.css |
.chart-swatch | chart.css |
.chart-tick | chart.css |
.chart-tip | chart.css |
.chart-tip-row | chart.css |
.chart-tip-title | chart.css |
.chart-tip-value | chart.css |
.chart-value | chart.css |
.chart-zero | chart.css |
.chart-guide | line-chart.css |
.chart-point | line-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
| Keys | Action |
|---|---|
| Arrow keys | Move between them and Escape hides the tooltip |