Charts

Labelled Line Chart Card

Card with a single-series line chart of average session minutes by month, each point labelled with its value, and a footer note on the trend. Client component on recharts 3.8.

Free, MIT licenseOpen in Browse
"use client"

import { CartesianGrid, LabelList, Line, LineChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  type ChartConfig,
} from "@/components/ui/chart"

// The copy: change text here, not in the markup.
const COPY = {
  title: "Average session",
  description: "Minutes per session, May to October 2026",
  note: "Sessions run longer since offline albums shipped in August.",
} as const

const AVERAGE_SESSION = [
  { month: "May", minutes: 21 },
  { month: "June", minutes: 24 },
  { month: "July", minutes: 23 },
  { month: "August", minutes: 29 },
  { month: "September", minutes: 33 },
  { month: "October", minutes: 35 },
]

const CHART_CONFIG = {
  minutes: { label: "Minutes", color: "var(--chart-2)" },
} satisfies ChartConfig

export default function LineChart01() {
  return (
    <Card className="mx-auto w-full max-w-md">
      <CardHeader>
        <CardTitle>
          <h2>{COPY.title}</h2>
        </CardTitle>
        <CardDescription>{COPY.description}</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer config={CHART_CONFIG}>
          <LineChart
            accessibilityLayer
            data={AVERAGE_SESSION}
            margin={{ top: 24, left: 16, right: 16 }}
          >
            <CartesianGrid vertical={false} />
            {/* Stock ChartContainer's label color misses recharts 3's label layer. */}
            <XAxis
              tick={{ fill: "var(--muted-foreground)" }}
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              cursor={false}
              content={<ChartTooltipContent indicator="line" />}
            />
            <Line
              dataKey="minutes"
              type="natural"
              stroke="var(--color-minutes)"
              strokeWidth={2}
              dot={{ fill: "var(--color-minutes)" }}
              activeDot={{ r: 6 }}
            >
              <LabelList
                position="top"
                offset={12}
                className="fill-foreground"
                fontSize={12}
              />
            </Line>
          </LineChart>
        </ChartContainer>
      </CardContent>
      <CardFooter className="text-sm text-muted-foreground">
        <p>{COPY.note}</p>
      </CardFooter>
    </Card>
  )
}

Installation

pnpm dlx shadcn add @01orbital/line-chart-01
npx shadcn add @01orbital/line-chart-01
yarn shadcn add @01orbital/line-chart-01
bunx --bun shadcn add @01orbital/line-chart-01

Free under the MIT license. Add the @01orbital registry to components.json once (install guide), then run the command.

It lands at components/blocks/charts/line-chart-01/index.tsx, as source you own and edit.

Usage

import LineChart01 from "@/components/blocks/charts/line-chart-01"

export default function Example() {
  return <LineChart01 />
}

Dependencies

npm: recharts@3.8.0. The CLI installs them for you.

Registry pieces it installs with it:

  • card
  • chart