LineChart

A line chart component for intuitively visualizing trends and changes over time — supports four curve styles (linear, monotone, step, natural) and per-series hover highlighting.

4
Types
5
Colors
4
Curve
Recharts
Base

Playground

Preview
Multiple
Type
Series
Style
Options
<Chart config={chartConfig} className="min-h-[200px]">
  <LineChart accessibilityLayer data={chartData}>
    <CartesianGrid vertical={false} />
    <ChartXAxis dataKey="month" tickLine={false} tickMargin={10} axisLine={false} />
    <ChartTooltip content={<ChartTooltipContent />} />
    <ChartLegend content={<ChartLegendContent />} />
    <ChartLine dataKey="desktop" stroke="var(--color-desktop)" />
    <ChartLine dataKey="mobile" stroke="var(--color-mobile)" />
  </LineChart>
</Chart>

JSX Composition

Chart.* from this library; import everything else from Recharts.

Grid<CartesianGrid />
Y-Axis<ChartYAxis />
Legend<ChartLegend /> (multiple series)
Labels<LabelList /> (single series)

Patterns

Common display patterns for LineChart — choose based on your use case.

Default

Basic single-series line chart

Multiple Lines

Multiple overlapping series for comparison

Step Line

Step-style line chart (type="step")

Dashed Line

Solid and dashed line combination (variant="dashed")

Tooltip Styles

Use theindicator prop on ChartTooltipContent to change the tooltip indicator shape.

Dot (default)

Default dot indicator

January
Desktop186
Mobile80
indicator="dot"

Line

Vertical line indicator

January
Desktop186
Mobile80
indicator="line"

Dashed

Dashed line indicator

January
Desktop186
Mobile80
indicator="dashed"

API

Component Structure

Chart— Recharts
.LineProps.XAxis.YAxis.Tooltip.TooltipContentProps.Legend.LegendContent

Props

Chart

config
ChartConfig

Chart configuration object — labels and color definitions

children
ReactElement

Recharts chart component

idundefined
string

Unique chart ID for CSS variable scoping

hoverFadefalse
boolean

Highlights the hovered series at full opacity and fades out all others

ChartLine

type"monotone"
"linear" | "monotone" | "step" | "natural"

Curve interpolation type — monotone for smooth curves, linear for straight lines, step for staircase, natural for natural spline

variant"solid"
"solid" | "dashed"

Line style — dashed renders as a dashed line

dottrue
boolean

Show data point dots

activeDottrue
boolean

Show active dot on hover

ChartTooltipContent

indicator"dot"
"dot" | "line" | "dashed"

Indicator shape in the tooltip

hideLabelfalse
boolean

Hide the label

hideIndicatorfalse
boolean

Hide the indicator

colorundefined
string

Override indicator color — falls back to payload color when unset

labelClassNameundefined
string

Additional CSS class for the label element

nameKeyundefined
string

Data key name mapping

labelKeyundefined
string

Label key mapping

labelFormatterundefined
(value, payload) => ReactNode

Custom formatter for the label

formatterundefined
(value, name, item, index, payload) => ReactNode

Custom formatter for values

ChartLegendContent

hideIconfalse
boolean

Hide the icon

nameKeyundefined
string

Data key name mapping

verticalAlign"bottom"
"top" | "middle" | "bottom"

Vertical position — auto-injected by Recharts Legend

align"center"
"left" | "center" | "right"

Horizontal alignment — auto-injected by Recharts Legend

layout"horizontal"
"horizontal" | "vertical"

Layout direction — auto-injected by Recharts Legend

ChartXAxis / ChartYAxis

tick{ style: { fontSize, fill } }
object

Axis label style — applies design tokens (--font-size-2xs, --color-text-subtle) by default, override with a custom object

width (YAxis)"auto"
number | "auto"

Y-axis width — auto adjusts to data when set to "auto", or fixed with a number

...props
XAxisProps | YAxisProps

All Recharts XAxis / YAxis props are passed through as-is

Anatomy

1
2
4
3002001000
8
5
6
3
JanFebMarAprMay
7
February
Desktop305
9
Desktop
Mobile
1
Root
Chart wrapper
2
Chart Area
Plot area
3
X-Axis
Horizontal axis
4
Y-Axis
Vertical axis
5
Line
Data line
6
Dot
Data point
7
Tooltip
Hover info
8
Grid
Grid lines
9
Legend
Series legend

Best Practices

Do

  • Use for time-series data and trend visualization
  • Always enable accessibilityLayer
  • Use variant="dashed" for projected values
  • Use design token colors

Don't

  • Don't use for category comparison — use BarChart instead
  • Don't pack more than 5 series into a single chart
  • Don't use monotone interpolation for discrete data — use step instead
  • Don't force comparisons without a grid

Accessibility

Keyboard

TabFocus the chart area
Arrow KeysMove between data points

ARIA / WCAG

  • accessibilityLayer keyboard + screen reader support
  • Tooltip provides data values as text
  • Legend identifies series visually
  • Color tokens automatically support dark mode