# Line Chart

Ten line charts for trends over time, from a single smooth line to dots, labels, goals, forecasts and several series.

Line Chart is an open-source chart from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

Source: https://suiss.app/ui/docs/charts/line-chart

Line charts follow a trend across time. Start with the default for one series, add dots or printed values when each reading matters, draw a goal line to show a target, and continue the line as a dashed forecast for values that have not happened yet. Linear and step lines avoid suggesting values between readings, and the multiple and interactive variants compare several series on the same axes.

Each chart is built on the [Chart](https://suiss.app/ui/docs/components/chart) and [Card](https://suiss.app/ui/docs/components/card) components.

Every variant below is its own registry item, so you can add only the ones you need. Each one renders the same design on React, React Native, SwiftUI and Jetpack Compose.


## Line Chart Default

A single smooth line through six months of values, without point markers.

Source: https://suiss.app/ui/docs/charts/line-chart#default

**React**

**Example**

```tsx title="components/charts/line-chart-default.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartDefault() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Line chart</CardTitle>
        <CardDescription>A smooth curve through each month</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="natural"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

The starting line chart: one smooth series without point markers, a month axis and a tooltip. Use it to show a trend over time when the overall shape matters more than individual readings.

Replace `chartData`, point each `dataKey` at your fields and set the label and color in `chartConfig`. Change the curve with `type` on the line, or set `dot` to show markers. Focus the chart and use the arrow keys to move the tooltip between months.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-default
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-default
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-default.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartDefault() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Line chart</CardTitle>
        <CardDescription>A smooth curve through each month</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="natural"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartDefault } from "@/components/charts/line-chart-default"
```

```tsx
<LineChartDefault />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-default.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartDefault() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Line chart</CardTitle>
        <CardDescription>A smooth curve through each month</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Line chart"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="natural" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartDefault.swift"
import Charts
import SwiftUI

private let chartData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
  ("May", 209, 130),
  ("June", 264, 140),
]

private let chartConfig: ChartConfig = [
  "desktop": .init("Desktop", color: EsuissColor.chart1),
]

public struct LineChartDefault: View {
  @State private var selection: Int?

  public init() {}

  public var body: some View {
    Card(.filled, size: .sm) {
      CardHeader("Line chart", description: "A smooth curve through each month")
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              ForEach(chartData.indices, id: \.self) { index in
                LineMark(x: .value("Month", index), y: .value("Desktop", chartData[index].desktop))
                  .interpolationMethod(.catmullRom)
                  .lineStyle(StrokeStyle(lineWidth: 2.5, lineCap: .round, lineJoin: .round))
                  .foregroundStyle(chartConfig.color("desktop"))
              }
              .chartReveal(progress, x: 0...(chartData.count - 1))
              if let selection {
                PointMark(x: .value("Month", selection), y: .value("Desktop", chartData[selection].desktop))
                  .symbolSize(64)
                  .foregroundStyle(chartConfig.color("desktop"))
              }
            }
            .chartXScale(domain: 0...(chartData.count - 1), range: .plotDimension(padding: 12))
            .chartXAxis { ChartAxis.x(values: Array(chartData.indices)) { String(chartData[$0].month.prefix(3)) } }
            .chartYAxis { ChartAxis.grid() }
            .chartTooltip(
              x: Array(chartData.indices),
              labels: chartData.map(\.month),
              selection: $selection,
              accessibilityLabel: "Line chart",
              items: { [ChartTooltipItem("desktop", value: chartData[$0].desktop)] }
            ) { payload in
              ChartTooltipContent(payload, hideLabel: true)
            }
          }
        }
        .frame(height: 192)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartDefault.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.LineChart

private class LineDefaultRow(val month: String, val desktop: Double, val mobile: Double)

private val chartData = listOf(
    LineDefaultRow("January", 186.0, 80.0),
    LineDefaultRow("February", 305.0, 200.0),
    LineDefaultRow("March", 237.0, 120.0),
    LineDefaultRow("April", 173.0, 190.0),
    LineDefaultRow("May", 209.0, 130.0),
    LineDefaultRow("June", 264.0, 140.0),
)

private val chartConfig = ChartConfig(
    "desktop" to ChartConfigItem("Desktop") { chart1 },
)

@Composable
fun LineChartDefault(modifier: Modifier = Modifier) {
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardHeader("Line chart", description = "A smooth curve through each month")
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(192.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 10.dp, right = 12.dp, bottom = 0.dp, left = 12.dp),
                    accessibilityLabel = "Line chart",
                ) {
                    CartesianGrid(strokeDasharray = listOf(2f, 4f))
                    XAxis(label = { it.month }, tickMargin = 8.dp, interval = 0, tickFormatter = { it.take(3) })
                    ChartTooltip { ChartTooltipContent(hideLabel = true) }
                    Line("desktop", value = { it.desktop }, curve = ChartCurve.Natural, strokeWidth = 2.5.dp)
                }
            }
        }
    }
}
```

The baseline line chart inside a `Card`: one series drawn as a natural curve with a month axis, a dashed horizontal grid and a tooltip. There is no value axis.

**React Native**

Replace `chartData` with your records and change each `dataKey` to match your fields. Set the label and color in `chartConfig`, and change the curve with the `type` prop on `Line`. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-default
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-default
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-default
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-default --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-default
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-default --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-default.tsx`:

- `uniwind/components/charts/line-chart-default.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-default.tsx`:

```tsx title="nativewind/components/charts/line-chart-default.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartDefault() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Line chart</CardTitle>
        <CardDescription>A smooth curve through each month</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Line chart"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="natural" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-default.tsx`:

```tsx title="stylesheet/components/charts/line-chart-default.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartDefault() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Line chart</CardTitle>
        <CardDescription>A smooth curve through each month</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Line chart"
          style={{ height: 192 }}
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="natural" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartDefault.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartDefault.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartDefault } from "@/components/charts/line-chart-default"
```

```tsx
<LineChartDefault />
```

**SwiftUI**

```swift
import SwiftUI

struct LineExample: View {
  var body: some View {
    LineChartDefault()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartDefault

@Composable
fun LineExample() {
    LineChartDefault()
}
```



## Line Chart Dots

A weight trend with a dot at every monthly reading and a fixed value axis on the right.

Source: https://suiss.app/ui/docs/charts/line-chart#dots

**React**

**Example**

```tsx title="components/charts/line-chart-dots.tsx"
"use client"

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

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

const chartData = [
  82.4, 81.6, 81.9, 80.8, 80.1, 79.6, 79.8, 78.9, 78.4, 77.9,
].map((weight, index) => ({
  month: new Intl.DateTimeFormat("en-US", { month: "short" }).format(
    new Date(2026, index, 1)
  ),
  weight,
}))

const chartConfig = {
  weight: { label: "Weight", color: "var(--color-purple-500)" },
} satisfies ChartConfig

export function LineChartDots() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader className="gap-0.5">
        <p className="text-sm font-semibold text-[color-mix(in_oklab,var(--color-purple-500),var(--foreground)_15%)] dark:text-purple-500">
          Weight
        </p>
        <p className="flex items-baseline gap-1">
          <span className="text-3xl font-semibold tracking-tight tabular-nums">
            77.9
          </span>
          <span className="text-base font-semibold text-muted-foreground">
            kg
          </span>
        </p>
        <p className="text-sm text-muted-foreground">
          Down 4.5 kg since January
        </p>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-40 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={2}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              domain={[76, 84]}
              ticks={[76, 80, 84]}
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <span className="font-semibold tabular-nums">
                      {value} kg
                    </span>
                  )}
                />
              }
            />
            <Line
              dataKey="weight"
              type="linear"
              stroke="var(--color-weight)"
              strokeWidth={2}
              dot={{ r: 3.5, fill: "var(--color-weight)", strokeWidth: 0 }}
              activeDot={{ r: 5 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A health-style weight card with a dot on every monthly reading and a fixed value axis on the right. The dots make it clear where measurements actually exist, so use this variant when readings are sparse or irregular.

Replace the readings in `chartData` and rename `weight` in the data, the line and `chartConfig`. Set the value axis `domain` and `ticks` to suit your numbers, and change the unit in the tooltip formatter. The headline value and the change below it are static text, so update them with the data or compute them from it.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-dots
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-dots
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-dots.tsx"
"use client"

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

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

const chartData = [
  82.4, 81.6, 81.9, 80.8, 80.1, 79.6, 79.8, 78.9, 78.4, 77.9,
].map((weight, index) => ({
  month: new Intl.DateTimeFormat("en-US", { month: "short" }).format(
    new Date(2026, index, 1)
  ),
  weight,
}))

const chartConfig = {
  weight: { label: "Weight", color: "var(--color-purple-500)" },
} satisfies ChartConfig

export function LineChartDots() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader className="gap-0.5">
        <p className="text-sm font-semibold text-[color-mix(in_oklab,var(--color-purple-500),var(--foreground)_15%)] dark:text-purple-500">
          Weight
        </p>
        <p className="flex items-baseline gap-1">
          <span className="text-3xl font-semibold tracking-tight tabular-nums">
            77.9
          </span>
          <span className="text-base font-semibold text-muted-foreground">
            kg
          </span>
        </p>
        <p className="text-sm text-muted-foreground">
          Down 4.5 kg since January
        </p>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-40 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={2}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              domain={[76, 84]}
              ticks={[76, 80, 84]}
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <span className="font-semibold tabular-nums">
                      {value} kg
                    </span>
                  )}
                />
              }
            />
            <Line
              dataKey="weight"
              type="linear"
              stroke="var(--color-weight)"
              strokeWidth={2}
              dot={{ r: 3.5, fill: "var(--color-weight)", strokeWidth: 0 }}
              activeDot={{ r: 5 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartDots } from "@/components/charts/line-chart-dots"
```

```tsx
<LineChartDots />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-dots.tsx"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"

const MONTHS = [
  "Jan",
  "Feb",
  "Mar",
  "Apr",
  "May",
  "Jun",
  "Jul",
  "Aug",
  "Sep",
  "Oct",
]

const chartData = [
  82.4, 81.6, 81.9, 80.8, 80.1, 79.6, 79.8, 78.9, 78.4, 77.9,
].map((weight, index) => ({ month: MONTHS[index] ?? "", weight }))

const chartConfig = {
  weight: { label: "Weight", color: "purple-500" },
} satisfies ChartConfig

export function LineChartDots() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader className="gap-0.5">
        <Text className="text-sm font-semibold text-purple-500">Weight</Text>
        <View className="flex-row items-baseline gap-1">
          <Text className="text-3xl font-semibold tracking-tight tabular-nums">
            77.9
          </Text>
          <Text className="text-base font-semibold text-muted-foreground">
            kg
          </Text>
        </View>
        <Text className="text-sm text-muted-foreground">
          Down 4.5 kg since January
        </Text>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Weight"
          className="h-40 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} interval={2} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[76, 84]}
              ticks={[76, 80, 84]}
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text className="font-semibold tabular-nums">
                      {String(value)} kg
                    </Text>
                  )}
                />
              }
            />
            <Line
              dataKey="weight"
              type="linear"
              strokeWidth={2}
              dot={{ r: 3.5 }}
              activeDot={{ r: 5 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartDots.swift"
import Charts
import SwiftUI

private let chartData: [(month: String, weight: Double)] = [
  ("Jan", 82.4), ("Feb", 81.6), ("Mar", 81.9), ("Apr", 80.8), ("May", 80.1),
  ("Jun", 79.6), ("Jul", 79.8), ("Aug", 78.9), ("Sep", 78.4), ("Oct", 77.9),
]

private let chartConfig: ChartConfig = [
  "weight": .init("Weight", color: Palette.purple500),
]

public struct LineChartDots: View {
  @State private var selection: Int?

  public init() {}

  public var body: some View {
    Card(.filled, size: .sm) {
      VStack(alignment: .leading, spacing: 2) {
        Text("Weight")
          .textStyle(.sm, weight: .semibold)
          .foregroundStyle(chartConfig.color("weight"))
        HStack(alignment: .firstTextBaseline, spacing: 4) {
          Text(verbatim: "77.9")
            .textStyle(.xl3, weight: .semibold)
            .monospacedDigit()
          Text("kg")
            .textStyle(.base, weight: .semibold)
            .foregroundStyle(EsuissColor.mutedForeground)
        }
        Text("Down 4.5 kg since January")
          .textStyle(.sm)
          .foregroundStyle(EsuissColor.mutedForeground)
      }
      .padding(.horizontal, 16)
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              ForEach(chartData.indices, id: \.self) { index in
                LineMark(x: .value("Month", index), y: .value("Weight", chartData[index].weight))
                  .interpolationMethod(.linear)
                  .lineStyle(StrokeStyle(lineWidth: 2, lineCap: .round, lineJoin: .round))
                  .foregroundStyle(chartConfig.color("weight"))
                PointMark(x: .value("Month", index), y: .value("Weight", chartData[index].weight))
                  .symbolSize(selection == index ? 100 : 49)
                  .foregroundStyle(chartConfig.color("weight"))
              }
              .chartReveal(progress, x: 0...(chartData.count - 1))
            }
            .chartXScale(domain: 0...(chartData.count - 1), range: .plotDimension(padding: 12))
            .chartYScale(domain: 76...84)
            .chartXAxis { ChartAxis.x(values: [0, 3, 6, 9]) { chartData[$0].month } }
            .chartYAxis { ChartAxis.y(values: [76, 80, 84]) { (value: Double) in value.formatted() } }
            .chartTooltip(
              x: Array(chartData.indices),
              labels: chartData.map(\.month),
              selection: $selection,
              accessibilityLabel: "Weight",
              items: { [ChartTooltipItem("weight", value: chartData[$0].weight)] }
            ) { payload in
              ChartTooltipContent(payload, hideIndicator: true) { item in
                Text("\(item.value, format: .number) kg")
                  .scaledFont(TextStyle.xs, weight: .semibold)
                  .monospacedDigit()
              }
            }
          }
        }
        .frame(height: 160)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartDots.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartAxisOrientation
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartDot
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.LineChart
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Palette
import com.esuiss.ui.theme.Typography

private class LineDotsRow(val month: String, val weight: Double)

private val months = listOf("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")

private val chartData = listOf(82.4, 81.6, 81.9, 80.8, 80.1, 79.6, 79.8, 78.9, 78.4, 77.9)
    .mapIndexed { index, weight -> LineDotsRow(months[index], weight) }

private val chartConfig = ChartConfig(
    "weight" to ChartConfigItem("Weight") { Palette.purple500 },
)

@Composable
fun LineChartDots(modifier: Modifier = Modifier) {
    val colors = EsuissTheme.colors
    val number = Typography.xl3.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold, fontFeatureSettings = "tnum")
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardContent {
            Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
                BasicText(
                    "Weight",
                    style = Typography.sm.copy(
                        color = if (colors.isDark) Palette.purple500 else lerp(Palette.purple500, colors.foreground, 0.15f),
                        fontWeight = FontWeight.SemiBold,
                    ),
                )
                Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
                    BasicText("77.9", Modifier.alignByBaseline(), style = number)
                    BasicText(
                        "kg",
                        Modifier.alignByBaseline(),
                        style = Typography.base.copy(color = colors.mutedForeground, fontWeight = FontWeight.SemiBold),
                    )
                }
                BasicText("Down 4.5 kg since January", style = Typography.sm.copy(color = colors.mutedForeground))
            }
        }
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(160.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 10.dp, right = 4.dp, bottom = 0.dp, left = 12.dp),
                    accessibilityLabel = "Weight",
                ) {
                    CartesianGrid(strokeDasharray = listOf(2f, 4f))
                    XAxis(label = { it.month }, tickMargin = 8.dp, interval = 2)
                    YAxis(
                        orientation = ChartAxisOrientation.Right,
                        tickMargin = 6.dp,
                        domain = 76.0..84.0,
                        ticks = listOf(76.0, 80.0, 84.0),
                        tickFormatter = { it.toInt().toString() },
                    )
                    ChartTooltip {
                        ChartTooltipContent(
                            hideIndicator = true,
                            formatter = { item ->
                                BasicText(
                                    "${item.value} kg",
                                    style = Typography.xs.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold, fontFeatureSettings = "tnum"),
                                )
                            },
                        )
                    }
                    Line(
                        "weight",
                        value = { it.weight },
                        strokeWidth = 2.dp,
                        dot = ChartDot(3.5.dp),
                        activeDot = ChartDot(5.dp),
                    )
                }
            }
        }
    }
}
```

**React Native**

Ten monthly weights drawn with `type="linear"` and a dot on every reading, plus a larger dot for the touched point. A value axis on the right covers a fixed range, and the tooltip formats values in kilograms. The header shows the latest weight and the change since January as static text.

Replace the weight array in `chartData` and update the header text to match. Adjust the `YAxis` `domain` and `ticks` for your range. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-dots
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-dots
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-dots
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-dots --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-dots
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-dots --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-dots.tsx`:

- `uniwind/components/charts/line-chart-dots.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-dots.tsx`:

```tsx title="nativewind/components/charts/line-chart-dots.tsx"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"

const MONTHS = [
  "Jan",
  "Feb",
  "Mar",
  "Apr",
  "May",
  "Jun",
  "Jul",
  "Aug",
  "Sep",
  "Oct",
]

const chartData = [
  82.4, 81.6, 81.9, 80.8, 80.1, 79.6, 79.8, 78.9, 78.4, 77.9,
].map((weight, index) => ({ month: MONTHS[index] ?? "", weight }))

const chartConfig = {
  weight: { label: "Weight", color: "purple-500" },
} satisfies ChartConfig

export function LineChartDots() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader className="gap-0.5">
        <Text className="text-sm font-semibold text-purple-500">Weight</Text>
        <View className="flex-row items-baseline gap-1">
          <Text className="text-3xl font-semibold tracking-tight tabular-nums">
            77.9
          </Text>
          <Text className="text-base font-semibold text-muted-foreground">
            kg
          </Text>
        </View>
        <Text className="text-sm text-muted-foreground">
          Down 4.5 kg since January
        </Text>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Weight"
          className="h-40 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} interval={2} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[76, 84]}
              ticks={[76, 80, 84]}
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text className="font-semibold tabular-nums">
                      {String(value)} kg
                    </Text>
                  )}
                />
              }
            />
            <Line
              dataKey="weight"
              type="linear"
              strokeWidth={2}
              dot={{ r: 3.5 }}
              activeDot={{ r: 5 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-dots.tsx`:

```tsx title="stylesheet/components/charts/line-chart-dots.tsx"
import { StyleSheet, View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"
import { fontSize, palette, useTheme } from "@/components/ui/theme"

const MONTHS = [
  "Jan",
  "Feb",
  "Mar",
  "Apr",
  "May",
  "Jun",
  "Jul",
  "Aug",
  "Sep",
  "Oct",
]

const chartData = [
  82.4, 81.6, 81.9, 80.8, 80.1, 79.6, 79.8, 78.9, 78.4, 77.9,
].map((weight, index) => ({ month: MONTHS[index] ?? "", weight }))

const chartConfig = {
  weight: { label: "Weight", color: "purple-500" },
} satisfies ChartConfig

const styles = StyleSheet.create({
  header: { gap: 2 },
  eyebrow: { ...fontSize.sm, fontWeight: "600" },
  reading: { flexDirection: "row", alignItems: "baseline", gap: 4 },
  value: {
    ...fontSize["3xl"],
    fontWeight: "600",
    letterSpacing: -0.75,
    fontVariant: ["tabular-nums"],
  },
  unit: { ...fontSize.base, fontWeight: "600" },
  caption: { ...fontSize.sm },
  strong: { fontWeight: "600", fontVariant: ["tabular-nums"] },
  chart: { height: 160 },
})

export function LineChartDots() {
  const { colors } = useTheme()
  return (
    <Card variant="filled" size="sm">
      <CardHeader style={styles.header}>
        <Text style={[styles.eyebrow, { color: palette.purple500 }]}>
          Weight
        </Text>
        <View style={styles.reading}>
          <Text style={styles.value}>77.9</Text>
          <Text style={[styles.unit, { color: colors.mutedForeground }]}>
            kg
          </Text>
        </View>
        <Text style={[styles.caption, { color: colors.mutedForeground }]}>
          Down 4.5 kg since January
        </Text>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Weight"
          style={styles.chart}
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} interval={2} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[76, 84]}
              ticks={[76, 80, 84]}
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text style={styles.strong}>{String(value)} kg</Text>
                  )}
                />
              }
            />
            <Line
              dataKey="weight"
              type="linear"
              strokeWidth={2}
              dot={{ r: 3.5 }}
              activeDot={{ r: 5 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartDots.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartDots.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartDots } from "@/components/charts/line-chart-dots"
```

```tsx
<LineChartDots />
```

**SwiftUI**

```swift
import SwiftUI

struct LineDotsExample: View {
  var body: some View {
    LineChartDots()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartDots

@Composable
fun LineDotsExample() {
    LineChartDots()
}
```



## Line Chart Forecast

A solid line for actual values that continues as a dashed forecast over a shaded future range.

Source: https://suiss.app/ui/docs/charts/line-chart#forecast

**React**

**Example**

```tsx title="components/charts/line-chart-forecast.tsx"
"use client"

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

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

const actual = [12, 14, 13, 17, 19, 22, 24, 23, 26]
const forecast = [26, 28, 30, 33]

const chartData = Array.from({ length: 12 }, (_, index) => ({
  month: new Intl.DateTimeFormat("en-US", { month: "short" }).format(
    new Date(2026, index, 1)
  ),
  actual: actual[index] ?? null,
  forecast: index >= 8 ? forecast[index - 8] : null,
}))

const chartConfig = {
  actual: { label: "Actual", color: "var(--chart-1)" },
  forecast: { label: "Forecast", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartForecast() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Actual and forecast</CardTitle>
        <CardDescription>The dashed line is the forecast</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={2}
            />
            <ChartTooltip content={<ChartTooltipContent indicator="line" />} />
            <ReferenceArea
              x1="Sep"
              x2="Dec"
              fill="var(--secondary)"
              fillOpacity={0.6}
            />
            <Line
              dataKey="actual"
              type="monotone"
              stroke="var(--color-actual)"
              strokeWidth={2.5}
              dot={false}
            />
            <Line
              dataKey="forecast"
              type="monotone"
              stroke="var(--color-forecast)"
              strokeWidth={2.5}
              strokeDasharray="5 5"
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

Actual values drawn as a solid line that continues as a dashed forecast over a shaded future period. Use it whenever you show projections next to history and need readers to tell them apart.

Fill the `actual` and `forecast` arrays and start the forecast with the last actual value so the lines meet; at that point the tooltip lists both values. Move the shaded period with `x1` and `x2` on the reference area. Both series share one color in `chartConfig`, so the dash pattern, the shading and the series names in the tooltip tell them apart.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-forecast
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-forecast
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-forecast.tsx"
"use client"

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

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

const actual = [12, 14, 13, 17, 19, 22, 24, 23, 26]
const forecast = [26, 28, 30, 33]

const chartData = Array.from({ length: 12 }, (_, index) => ({
  month: new Intl.DateTimeFormat("en-US", { month: "short" }).format(
    new Date(2026, index, 1)
  ),
  actual: actual[index] ?? null,
  forecast: index >= 8 ? forecast[index - 8] : null,
}))

const chartConfig = {
  actual: { label: "Actual", color: "var(--chart-1)" },
  forecast: { label: "Forecast", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartForecast() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Actual and forecast</CardTitle>
        <CardDescription>The dashed line is the forecast</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={2}
            />
            <ChartTooltip content={<ChartTooltipContent indicator="line" />} />
            <ReferenceArea
              x1="Sep"
              x2="Dec"
              fill="var(--secondary)"
              fillOpacity={0.6}
            />
            <Line
              dataKey="actual"
              type="monotone"
              stroke="var(--color-actual)"
              strokeWidth={2.5}
              dot={false}
            />
            <Line
              dataKey="forecast"
              type="monotone"
              stroke="var(--color-forecast)"
              strokeWidth={2.5}
              strokeDasharray="5 5"
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartForecast } from "@/components/charts/line-chart-forecast"
```

```tsx
<LineChartForecast />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-forecast.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceArea,
  XAxis,
} from "@/components/ui/chart"

const MONTHS = [
  "Jan",
  "Feb",
  "Mar",
  "Apr",
  "May",
  "Jun",
  "Jul",
  "Aug",
  "Sep",
  "Oct",
  "Nov",
  "Dec",
]

const actual = [12, 14, 13, 17, 19, 22, 24, 23, 26]
const forecast = [26, 28, 30, 33]

const chartData = MONTHS.map((month, index) => ({
  month,
  actual: actual[index] ?? null,
  forecast: index >= 8 ? (forecast[index - 8] ?? null) : null,
}))

const chartConfig = {
  actual: { label: "Actual", color: "chart-1" },
  forecast: { label: "Forecast", color: "chart-1" },
} satisfies ChartConfig

export function LineChartForecast() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Actual and forecast</CardTitle>
        <CardDescription>The dashed line is the forecast</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Actual and forecast"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} interval={2} />
            <ChartTooltip content={<ChartTooltipContent indicator="line" />} />
            <ReferenceArea
              x1="Sep"
              x2="Dec"
              fill="secondary"
              fillOpacity={0.6}
            />
            <Line dataKey="actual" type="monotone" strokeWidth={2.5} />
            <Line
              dataKey="forecast"
              type="monotone"
              strokeWidth={2.5}
              strokeDasharray="5 5"
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartForecast.swift"
import Charts
import SwiftUI

private let actual: [Double] = [12, 14, 13, 17, 19, 22, 24, 23, 26]
private let forecast: [Double] = [26, 28, 30, 33]
private let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

private let chartConfig: ChartConfig = [
  "actual": .init("Actual", color: EsuissColor.chart1),
  "forecast": .init("Forecast", color: EsuissColor.chart1),
]

private func value(_ key: String, _ index: Int) -> Double? {
  if key == "actual" { return actual.indices.contains(index) ? actual[index] : nil }
  return index >= 8 ? forecast[index - 8] : nil
}

public struct LineChartForecast: View {
  @State private var selection: Int?

  public init() {}

  public var body: some View {
    Card(.filled, size: .sm) {
      CardHeader("Actual and forecast", description: "The dashed line is the forecast")
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              RectangleMark(xStart: .value("Month", 8), xEnd: .value("Month", 11))
                .foregroundStyle(EsuissColor.secondary.opacity(0.6))
              ForEach(chartConfig.keys, id: \.self) { key in
                ForEach(months.indices, id: \.self) { index in
                  if let point = value(key, index) {
                    LineMark(x: .value("Month", index), y: .value("Value", point), series: .value("Series", key))
                      .interpolationMethod(.monotone)
                      .lineStyle(StrokeStyle(lineWidth: 2.5, lineCap: .round, lineJoin: .round, dash: key == "forecast" ? [5, 5] : []))
                      .foregroundStyle(chartConfig.color(key))
                  }
                }
                if let selection, let point = value(key, selection) {
                  PointMark(x: .value("Month", selection), y: .value("Value", point))
                    .symbolSize(64)
                    .foregroundStyle(chartConfig.color(key))
                }
              }
              .chartReveal(progress, x: 0...11)
            }
            .chartXScale(domain: 0...11, range: .plotDimension(padding: 12))
            .chartXAxis { ChartAxis.x(values: [0, 3, 6, 9]) { months[$0] } }
            .chartYAxis { ChartAxis.grid() }
            .chartTooltip(
              x: Array(months.indices),
              labels: months,
              selection: $selection,
              accessibilityLabel: "Actual and forecast",
              items: { index in
                chartConfig.keys.compactMap { key in value(key, index).map { ChartTooltipItem(key, value: $0) } }
              }
            ) { payload in
              ChartTooltipContent(payload, indicator: .line)
            }
          }
        }
        .frame(height: 192)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartForecast.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.ChartTooltipIndicator
import com.esuiss.ui.components.LineChart
import com.esuiss.ui.theme.EsuissTheme

private class LineForecastRow(val month: String, val actual: Double?, val forecast: Double?)

private val actual = listOf(12.0, 14.0, 13.0, 17.0, 19.0, 22.0, 24.0, 23.0, 26.0)

private val forecast = listOf(26.0, 28.0, 30.0, 33.0)

private val chartData = listOf("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    .mapIndexed { index, month ->
        LineForecastRow(month, actual.getOrNull(index), if (index >= 8) forecast[index - 8] else null)
    }

private val chartConfig = ChartConfig(
    "actual" to ChartConfigItem("Actual") { chart1 },
    "forecast" to ChartConfigItem("Forecast") { chart1 },
)

@Composable
fun LineChartForecast(modifier: Modifier = Modifier) {
    val colors = EsuissTheme.colors
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardHeader("Actual and forecast", description = "The dashed line is the forecast")
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(192.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 10.dp, right = 12.dp, bottom = 0.dp, left = 12.dp),
                    accessibilityLabel = "Actual and forecast",
                ) {
                    CartesianGrid(strokeDasharray = listOf(2f, 4f))
                    XAxis(label = { it.month }, tickMargin = 8.dp, interval = 2)
                    ChartTooltip { ChartTooltipContent(indicator = ChartTooltipIndicator.Line) }
                    ReferenceArea(8, 11, fill = colors.secondary, fillOpacity = 0.6f)
                    Line("actual", value = { it.actual }, curve = ChartCurve.Monotone, strokeWidth = 2.5.dp)
                    Line(
                        "forecast",
                        value = { it.forecast },
                        curve = ChartCurve.Monotone,
                        strokeWidth = 2.5.dp,
                        strokeDasharray = listOf(5f, 5f),
                    )
                }
            }
        }
    }
}
```

**React Native, Jetpack Compose**

Two series share one axis: `actual` fills the first nine months and `forecast` continues from September, drawn with `strokeDasharray`. A `ReferenceArea` shades September to December to mark the forecast period. Missing values are `null`, so each line stops where its data ends.

**React Native**

Replace the `actual` and `forecast` arrays; the forecast starts at the index set in `chartData`. Move the `ReferenceArea` `x1` and `x2` to match your forecast range. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-forecast
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-forecast
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-forecast
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-forecast --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-forecast
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-forecast --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-forecast.tsx`:

- `uniwind/components/charts/line-chart-forecast.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-forecast.tsx`:

```tsx title="nativewind/components/charts/line-chart-forecast.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceArea,
  XAxis,
} from "@/components/ui/chart"

const MONTHS = [
  "Jan",
  "Feb",
  "Mar",
  "Apr",
  "May",
  "Jun",
  "Jul",
  "Aug",
  "Sep",
  "Oct",
  "Nov",
  "Dec",
]

const actual = [12, 14, 13, 17, 19, 22, 24, 23, 26]
const forecast = [26, 28, 30, 33]

const chartData = MONTHS.map((month, index) => ({
  month,
  actual: actual[index] ?? null,
  forecast: index >= 8 ? (forecast[index - 8] ?? null) : null,
}))

const chartConfig = {
  actual: { label: "Actual", color: "chart-1" },
  forecast: { label: "Forecast", color: "chart-1" },
} satisfies ChartConfig

export function LineChartForecast() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Actual and forecast</CardTitle>
        <CardDescription>The dashed line is the forecast</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Actual and forecast"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} interval={2} />
            <ChartTooltip content={<ChartTooltipContent indicator="line" />} />
            <ReferenceArea
              x1="Sep"
              x2="Dec"
              fill="secondary"
              fillOpacity={0.6}
            />
            <Line dataKey="actual" type="monotone" strokeWidth={2.5} />
            <Line
              dataKey="forecast"
              type="monotone"
              strokeWidth={2.5}
              strokeDasharray="5 5"
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-forecast.tsx`:

```tsx title="stylesheet/components/charts/line-chart-forecast.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceArea,
  XAxis,
} from "@/components/ui/chart"

const MONTHS = [
  "Jan",
  "Feb",
  "Mar",
  "Apr",
  "May",
  "Jun",
  "Jul",
  "Aug",
  "Sep",
  "Oct",
  "Nov",
  "Dec",
]

const actual = [12, 14, 13, 17, 19, 22, 24, 23, 26]
const forecast = [26, 28, 30, 33]

const chartData = MONTHS.map((month, index) => ({
  month,
  actual: actual[index] ?? null,
  forecast: index >= 8 ? (forecast[index - 8] ?? null) : null,
}))

const chartConfig = {
  actual: { label: "Actual", color: "chart-1" },
  forecast: { label: "Forecast", color: "chart-1" },
} satisfies ChartConfig

export function LineChartForecast() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Actual and forecast</CardTitle>
        <CardDescription>The dashed line is the forecast</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Actual and forecast"
          style={{ height: 192 }}
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} interval={2} />
            <ChartTooltip content={<ChartTooltipContent indicator="line" />} />
            <ReferenceArea
              x1="Sep"
              x2="Dec"
              fill="secondary"
              fillOpacity={0.6}
            />
            <Line dataKey="actual" type="monotone" strokeWidth={2.5} />
            <Line
              dataKey="forecast"
              type="monotone"
              strokeWidth={2.5}
              strokeDasharray="5 5"
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartForecast.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartForecast.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartForecast } from "@/components/charts/line-chart-forecast"
```

```tsx
<LineChartForecast />
```

**SwiftUI**

```swift
import SwiftUI

struct LineForecastExample: View {
  var body: some View {
    LineChartForecast()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartForecast

@Composable
fun LineForecastExample() {
    LineChartForecast()
}
```



## Line Chart Goal Dots

Nightly sleep hours with a goal line and dots colored green or orange depending on whether the goal was met.

Source: https://suiss.app/ui/docs/charts/line-chart#goal-dots

**React**

**Example**

```tsx title="components/charts/line-chart-goal-dots.tsx"
"use client"

import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "recharts"

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

const GOAL = 7

const chartData = [
  { day: "Mon", hours: 6.8 },
  { day: "Tue", hours: 7.4 },
  { day: "Wed", hours: 5.9 },
  { day: "Thu", hours: 7.9 },
  { day: "Fri", hours: 6.4 },
  { day: "Sat", hours: 8.6 },
  { day: "Sun", hours: 7.2 },
]

const AVERAGE =
  chartData.reduce((sum, item) => sum + item.hours, 0) / chartData.length

const chartConfig = {
  hours: { label: "Sleep", color: "var(--chart-3)" },
} satisfies ChartConfig

function formatHours(hours: number) {
  const minutes = Math.round(hours * 60)
  return `${Math.floor(minutes / 60)}h ${minutes % 60}m`
}

export function LineChartGoalDots() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader className="gap-0.5">
        <p className="text-sm font-semibold text-[color-mix(in_oklab,var(--color-indigo-500),var(--foreground)_10%)] dark:text-[color-mix(in_oklab,var(--color-indigo-500),var(--foreground)_35%)]">
          Sleep
        </p>
        <p className="flex items-baseline gap-1">
          <span className="text-3xl font-semibold tracking-tight tabular-nums">
            {formatHours(AVERAGE)}
          </span>
        </p>
        <p className="text-sm text-muted-foreground">
          Goal 7 hours · green nights met it
        </p>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-40 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 4, left: 16, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="day"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              domain={[5, 9]}
              ticks={[5, 7, 9]}
              tickFormatter={(value: number) => `${value}h`}
            />
            <ReferenceLine
              y={GOAL}
              stroke="var(--color-green-500)"
              strokeDasharray="3 3"
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <span className="font-semibold tabular-nums">
                      {formatHours(Number(value))}
                    </span>
                  )}
                />
              }
            />
            <Line
              dataKey="hours"
              type="monotone"
              stroke="var(--color-hours)"
              strokeWidth={2}
              dot={({ cx, cy, index, payload }) => (
                <circle
                  key={index}
                  cx={cx}
                  cy={cy}
                  r={4.5}
                  fill={
                    payload.hours >= GOAL
                      ? "var(--color-green-500)"
                      : "var(--color-orange-500)"
                  }
                  stroke="var(--muted)"
                  strokeWidth={2}
                />
              )}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

Nightly sleep plotted against a dashed goal line, with each dot colored green if the goal was met and orange if not. Pick it over the plain goal chart when readers should spot hits and misses at a glance.

Replace `chartData` and set `GOAL` to your target; the dot colors follow the comparison. Adjust the value axis `domain` and `ticks`, and change the two dot colors in the custom `dot` renderer. The headline figure is static text, so wire it up to real values. Color alone marks a hit or miss on the chart, so keep a text explanation like the one in the header.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-goal-dots
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-goal-dots
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-goal-dots.tsx"
"use client"

import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "recharts"

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

const GOAL = 7

const chartData = [
  { day: "Mon", hours: 6.8 },
  { day: "Tue", hours: 7.4 },
  { day: "Wed", hours: 5.9 },
  { day: "Thu", hours: 7.9 },
  { day: "Fri", hours: 6.4 },
  { day: "Sat", hours: 8.6 },
  { day: "Sun", hours: 7.2 },
]

const AVERAGE =
  chartData.reduce((sum, item) => sum + item.hours, 0) / chartData.length

const chartConfig = {
  hours: { label: "Sleep", color: "var(--chart-3)" },
} satisfies ChartConfig

function formatHours(hours: number) {
  const minutes = Math.round(hours * 60)
  return `${Math.floor(minutes / 60)}h ${minutes % 60}m`
}

export function LineChartGoalDots() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader className="gap-0.5">
        <p className="text-sm font-semibold text-[color-mix(in_oklab,var(--color-indigo-500),var(--foreground)_10%)] dark:text-[color-mix(in_oklab,var(--color-indigo-500),var(--foreground)_35%)]">
          Sleep
        </p>
        <p className="flex items-baseline gap-1">
          <span className="text-3xl font-semibold tracking-tight tabular-nums">
            {formatHours(AVERAGE)}
          </span>
        </p>
        <p className="text-sm text-muted-foreground">
          Goal 7 hours · green nights met it
        </p>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-40 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 4, left: 16, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="day"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              domain={[5, 9]}
              ticks={[5, 7, 9]}
              tickFormatter={(value: number) => `${value}h`}
            />
            <ReferenceLine
              y={GOAL}
              stroke="var(--color-green-500)"
              strokeDasharray="3 3"
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <span className="font-semibold tabular-nums">
                      {formatHours(Number(value))}
                    </span>
                  )}
                />
              }
            />
            <Line
              dataKey="hours"
              type="monotone"
              stroke="var(--color-hours)"
              strokeWidth={2}
              dot={({ cx, cy, index, payload }) => (
                <circle
                  key={index}
                  cx={cx}
                  cy={cy}
                  r={4.5}
                  fill={
                    payload.hours >= GOAL
                      ? "var(--color-green-500)"
                      : "var(--color-orange-500)"
                  }
                  stroke="var(--muted)"
                  strokeWidth={2}
                />
              )}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartGoalDots } from "@/components/charts/line-chart-goal-dots"
```

```tsx
<LineChartGoalDots />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-goal-dots.tsx"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"

const GOAL = 7

const chartData = [
  { day: "Mon", hours: 6.8 },
  { day: "Tue", hours: 7.4 },
  { day: "Wed", hours: 5.9 },
  { day: "Thu", hours: 7.9 },
  { day: "Fri", hours: 6.4 },
  { day: "Sat", hours: 8.6 },
  { day: "Sun", hours: 7.2 },
]

const chartConfig = {
  hours: { label: "Sleep", color: "chart-3" },
} satisfies ChartConfig

function formatHours(hours: number) {
  const minutes = Math.round(hours * 60)
  return `${Math.floor(minutes / 60)}h ${minutes % 60}m`
}

export function LineChartGoalDots() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader className="gap-0.5">
        <Text className="text-sm font-semibold text-indigo-500">Sleep</Text>
        <View className="flex-row items-baseline gap-1">
          <Text className="text-3xl font-semibold tracking-tight tabular-nums">
            7h 9m
          </Text>
        </View>
        <Text className="text-sm text-muted-foreground">
          Goal 7 hours · green nights met it
        </Text>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Sleep"
          className="h-40 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 16, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="day" tickMargin={8} interval={0} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[5, 9]}
              ticks={[5, 7, 9]}
              tickFormatter={(value: number) => `${value}h`}
            />
            <ReferenceLine y={GOAL} stroke="green-500" strokeDasharray="3 3" />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text className="font-semibold tabular-nums">
                      {formatHours(Number(value))}
                    </Text>
                  )}
                />
              }
            />
            <Line
              dataKey="hours"
              type="monotone"
              strokeWidth={2}
              dot={({ index }) => ({
                r: 4.5,
                fill:
                  (chartData[index]?.hours ?? 0) >= GOAL
                    ? "green-500"
                    : "chart-4",
                stroke: "muted",
                strokeWidth: 2,
              })}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartGoalDots.swift"
import Charts
import SwiftUI

private let goal = 7.0

private let chartData: [(day: String, hours: Double)] = [
  ("Mon", 6.8), ("Tue", 7.4), ("Wed", 5.9), ("Thu", 7.9), ("Fri", 6.4), ("Sat", 8.6), ("Sun", 7.2),
]

private let chartConfig: ChartConfig = [
  "hours": .init("Sleep", color: EsuissColor.chart3),
]

private func formatHours(_ hours: Double) -> String {
  let minutes = Int((hours * 60).rounded())
  return "\(minutes / 60)h \(minutes % 60)m"
}

public struct LineChartGoalDots: View {
  @State private var selection: Int?

  public init() {}

  public var body: some View {
    Card(.filled, size: .sm) {
      VStack(alignment: .leading, spacing: 2) {
        Text("Sleep")
          .textStyle(.sm, weight: .semibold)
          .foregroundStyle(chartConfig.color("hours"))
        Text(verbatim: "7h 9m")
          .textStyle(.xl3, weight: .semibold)
          .monospacedDigit()
        Text("Goal 7 hours · green nights met it")
          .textStyle(.sm)
          .foregroundStyle(EsuissColor.mutedForeground)
      }
      .padding(.horizontal, 16)
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              RuleMark(y: .value("Goal", goal))
                .lineStyle(StrokeStyle(lineWidth: 1, dash: [3, 3]))
                .foregroundStyle(Palette.green500)
              ForEach(chartData.indices, id: \.self) { index in
                LineMark(x: .value("Day", index), y: .value("Hours", chartData[index].hours))
                  .interpolationMethod(.monotone)
                  .lineStyle(StrokeStyle(lineWidth: 2, lineCap: .round, lineJoin: .round))
                  .foregroundStyle(chartConfig.color("hours"))
              }
              .chartReveal(progress, x: 0...(chartData.count - 1))
              ForEach(chartData.indices, id: \.self) { index in
                PointMark(x: .value("Day", index), y: .value("Hours", chartData[index].hours))
                  .symbol {
                    Circle()
                      .fill(chartData[index].hours >= goal ? Palette.green500 : Palette.orange500)
                      .stroke(EsuissColor.muted, lineWidth: 2)
                      .frame(width: selection == index ? 13 : 11, height: selection == index ? 13 : 11)
                  }
              }
              .chartReveal(progress, x: 0...(chartData.count - 1))
            }
            .chartXScale(domain: 0...(chartData.count - 1), range: .plotDimension(padding: 16))
            .chartYScale(domain: 5...9)
            .chartXAxis { ChartAxis.x(values: Array(chartData.indices)) { chartData[$0].day } }
            .chartYAxis { ChartAxis.y(values: [5.0, 7, 9]) { "\($0.formatted())h" } }
            .chartTooltip(
              x: Array(chartData.indices),
              labels: chartData.map(\.day),
              selection: $selection,
              accessibilityLabel: "Sleep",
              items: { [ChartTooltipItem("hours", value: chartData[$0].hours)] }
            ) { payload in
              ChartTooltipContent(payload, hideIndicator: true) { item in
                Text(verbatim: formatHours(item.value))
                  .scaledFont(TextStyle.xs, weight: .semibold)
                  .monospacedDigit()
              }
            }
          }
        }
        .frame(height: 160)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartGoalDots.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartAxisOrientation
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartDot
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.LineChart
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Palette
import com.esuiss.ui.theme.Typography
import kotlin.math.roundToInt

private const val GOAL = 7.0

private class LineGoalDotsRow(val day: String, val hours: Double)

private val chartData = listOf(
    LineGoalDotsRow("Mon", 6.8),
    LineGoalDotsRow("Tue", 7.4),
    LineGoalDotsRow("Wed", 5.9),
    LineGoalDotsRow("Thu", 7.9),
    LineGoalDotsRow("Fri", 6.4),
    LineGoalDotsRow("Sat", 8.6),
    LineGoalDotsRow("Sun", 7.2),
)

private val chartConfig = ChartConfig(
    "hours" to ChartConfigItem("Sleep") { chart3 },
)

private fun formatHours(hours: Double): String {
    val minutes = (hours * 60).roundToInt()
    return "${minutes / 60}h ${minutes % 60}m"
}

@Composable
fun LineChartGoalDots(modifier: Modifier = Modifier) {
    val colors = EsuissTheme.colors
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardContent {
            Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
                BasicText(
                    "Sleep",
                    style = Typography.sm.copy(
                        color = lerp(colors.chart3, colors.foreground, if (colors.isDark) 0.35f else 0.1f),
                        fontWeight = FontWeight.SemiBold,
                    ),
                )
                BasicText(
                    "7h 9m",
                    style = Typography.xl3.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold, fontFeatureSettings = "tnum"),
                )
                BasicText("Goal 7 hours · green nights met it", style = Typography.sm.copy(color = colors.mutedForeground))
            }
        }
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(160.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 10.dp, right = 4.dp, bottom = 0.dp, left = 16.dp),
                    accessibilityLabel = "Sleep",
                ) {
                    CartesianGrid(strokeDasharray = listOf(2f, 4f))
                    XAxis(label = { it.day }, tickMargin = 8.dp, interval = 0)
                    YAxis(
                        orientation = ChartAxisOrientation.Right,
                        tickMargin = 6.dp,
                        domain = 5.0..9.0,
                        ticks = listOf(5.0, 7.0, 9.0),
                        tickFormatter = { "${it.toInt()}h" },
                    )
                    ReferenceLine(GOAL, stroke = Palette.green500, strokeDasharray = listOf(3f, 3f))
                    ChartTooltip {
                        ChartTooltipContent(
                            hideIndicator = true,
                            formatter = { item ->
                                BasicText(
                                    formatHours(item.value),
                                    style = Typography.xs.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold, fontFeatureSettings = "tnum"),
                                )
                            },
                        )
                    }
                    Line(
                        "hours",
                        value = { it.hours },
                        curve = ChartCurve.Monotone,
                        strokeWidth = 2.dp,
                        dot = ChartDot(4.5.dp, strokeColor = colors.muted, strokeWidth = 2.dp),
                        dotColor = { if (it.hours >= GOAL) Palette.green500 else colors.chart4 },
                    )
                }
            }
        }
    }
}
```

**React Native**

Seven nights of sleep drawn as a monotone line. The `dot` prop is a function that colors each point by comparing it with `GOAL`, and a dashed green `ReferenceLine` marks the goal itself. The tooltip formats values as hours and minutes.

Replace `chartData` with your nightly hours and set `GOAL`. The header average is static text, so update it with your own value. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-goal-dots
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-goal-dots
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-goal-dots
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-goal-dots --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-goal-dots
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-goal-dots --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-goal-dots.tsx`:

- `uniwind/components/charts/line-chart-goal-dots.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-goal-dots.tsx`:

```tsx title="nativewind/components/charts/line-chart-goal-dots.tsx"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"

const GOAL = 7

const chartData = [
  { day: "Mon", hours: 6.8 },
  { day: "Tue", hours: 7.4 },
  { day: "Wed", hours: 5.9 },
  { day: "Thu", hours: 7.9 },
  { day: "Fri", hours: 6.4 },
  { day: "Sat", hours: 8.6 },
  { day: "Sun", hours: 7.2 },
]

const chartConfig = {
  hours: { label: "Sleep", color: "chart-3" },
} satisfies ChartConfig

function formatHours(hours: number) {
  const minutes = Math.round(hours * 60)
  return `${Math.floor(minutes / 60)}h ${minutes % 60}m`
}

export function LineChartGoalDots() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader className="gap-0.5">
        <Text className="text-sm font-semibold text-indigo-500">Sleep</Text>
        <View className="flex-row items-baseline gap-1">
          <Text className="text-3xl font-semibold tracking-tight tabular-nums">
            7h 9m
          </Text>
        </View>
        <Text className="text-sm text-muted-foreground">
          Goal 7 hours · green nights met it
        </Text>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Sleep"
          className="h-40 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 16, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="day" tickMargin={8} interval={0} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[5, 9]}
              ticks={[5, 7, 9]}
              tickFormatter={(value: number) => `${value}h`}
            />
            <ReferenceLine y={GOAL} stroke="green-500" strokeDasharray="3 3" />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text className="font-semibold tabular-nums">
                      {formatHours(Number(value))}
                    </Text>
                  )}
                />
              }
            />
            <Line
              dataKey="hours"
              type="monotone"
              strokeWidth={2}
              dot={({ index }) => ({
                r: 4.5,
                fill:
                  (chartData[index]?.hours ?? 0) >= GOAL
                    ? "green-500"
                    : "chart-4",
                stroke: "muted",
                strokeWidth: 2,
              })}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-goal-dots.tsx`:

```tsx title="stylesheet/components/charts/line-chart-goal-dots.tsx"
import { StyleSheet, View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"
import { fontSize, useTheme } from "@/components/ui/theme"

const GOAL = 7

const chartData = [
  { day: "Mon", hours: 6.8 },
  { day: "Tue", hours: 7.4 },
  { day: "Wed", hours: 5.9 },
  { day: "Thu", hours: 7.9 },
  { day: "Fri", hours: 6.4 },
  { day: "Sat", hours: 8.6 },
  { day: "Sun", hours: 7.2 },
]

const chartConfig = {
  hours: { label: "Sleep", color: "chart-3" },
} satisfies ChartConfig

const styles = StyleSheet.create({
  header: { gap: 2 },
  eyebrow: { ...fontSize.sm, fontWeight: "600" },
  reading: { flexDirection: "row", alignItems: "baseline", gap: 4 },
  value: {
    ...fontSize["3xl"],
    fontWeight: "600",
    letterSpacing: -0.75,
    fontVariant: ["tabular-nums"],
  },
  caption: { ...fontSize.sm },
  strong: { fontWeight: "600", fontVariant: ["tabular-nums"] },
  chart: { height: 160 },
})

function formatHours(hours: number) {
  const minutes = Math.round(hours * 60)
  return `${Math.floor(minutes / 60)}h ${minutes % 60}m`
}

export function LineChartGoalDots() {
  const { colors } = useTheme()
  return (
    <Card variant="filled" size="sm">
      <CardHeader style={styles.header}>
        <Text style={[styles.eyebrow, { color: colors.chart3 }]}>Sleep</Text>
        <View style={styles.reading}>
          <Text style={styles.value}>7h 9m</Text>
        </View>
        <Text style={[styles.caption, { color: colors.mutedForeground }]}>
          Goal 7 hours · green nights met it
        </Text>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Sleep"
          style={styles.chart}
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 16, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="day" tickMargin={8} interval={0} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[5, 9]}
              ticks={[5, 7, 9]}
              tickFormatter={(value: number) => `${value}h`}
            />
            <ReferenceLine y={GOAL} stroke="green-500" strokeDasharray="3 3" />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text style={styles.strong}>
                      {formatHours(Number(value))}
                    </Text>
                  )}
                />
              }
            />
            <Line
              dataKey="hours"
              type="monotone"
              strokeWidth={2}
              dot={({ index }) => ({
                r: 4.5,
                fill:
                  (chartData[index]?.hours ?? 0) >= GOAL
                    ? "green-500"
                    : "chart-4",
                stroke: "muted",
                strokeWidth: 2,
              })}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartGoalDots.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartGoalDots.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartGoalDots } from "@/components/charts/line-chart-goal-dots"
```

```tsx
<LineChartGoalDots />
```

**SwiftUI**

```swift
import SwiftUI

struct LineGoalDotsExample: View {
  var body: some View {
    LineChartGoalDots()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartGoalDots

@Composable
fun LineGoalDotsExample() {
    LineChartGoalDots()
}
```



## Line Chart Goal

Daily step counts plotted against a labeled dashed goal line at 10,000 steps.

Source: https://suiss.app/ui/docs/charts/line-chart#goal

**React**

**Example**

```tsx title="components/charts/line-chart-goal.tsx"
"use client"

import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "recharts"

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

const GOAL = 10000

const chartData = [
  { day: "Mon", steps: 8412 },
  { day: "Tue", steps: 10230 },
  { day: "Wed", steps: 6120 },
  { day: "Thu", steps: 12480 },
  { day: "Fri", steps: 9050 },
  { day: "Sat", steps: 14320 },
  { day: "Sun", steps: 4870 },
]

const chartConfig = {
  steps: { label: "Steps", color: "var(--chart-4)" },
} satisfies ChartConfig

const stepsFormat = new Intl.NumberFormat("en-US")

export function LineChartGoal() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Goal line</CardTitle>
        <CardDescription>A daily goal of 10,000 steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="day"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              tickFormatter={(value: number) => `${value / 1000}k`}
            />
            <ReferenceLine
              y={GOAL}
              stroke="var(--color-green-500)"
              strokeDasharray="4 4"
              label={{
                value: "Goal",
                position: "insideTopLeft",
                className: "fill-muted-foreground text-xs font-semibold",
              }}
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <span className="font-semibold tabular-nums">
                      {stepsFormat.format(Number(value))} steps
                    </span>
                  )}
                />
              }
            />
            <Line
              dataKey="steps"
              type="monotone"
              stroke="var(--color-steps)"
              strokeWidth={2.5}
              dot={{ r: 3.5, fill: "var(--color-steps)", strokeWidth: 0 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

Daily steps as a line with dots, plotted against a labeled dashed goal line. Use it when a single target gives the values their meaning, such as quotas, budgets or fitness goals.

Replace `chartData` and set `GOAL` to your target. Change the label on the `ReferenceLine`, the unit in the tooltip formatter and the axis `tickFormatter` to fit your metric. The value axis scales to the data only, so set a `domain` if the goal can fall outside it. Focus the chart and use the arrow keys to step through the days.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-goal
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-goal
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-goal.tsx"
"use client"

import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "recharts"

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

const GOAL = 10000

const chartData = [
  { day: "Mon", steps: 8412 },
  { day: "Tue", steps: 10230 },
  { day: "Wed", steps: 6120 },
  { day: "Thu", steps: 12480 },
  { day: "Fri", steps: 9050 },
  { day: "Sat", steps: 14320 },
  { day: "Sun", steps: 4870 },
]

const chartConfig = {
  steps: { label: "Steps", color: "var(--chart-4)" },
} satisfies ChartConfig

const stepsFormat = new Intl.NumberFormat("en-US")

export function LineChartGoal() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Goal line</CardTitle>
        <CardDescription>A daily goal of 10,000 steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="day"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              tickFormatter={(value: number) => `${value / 1000}k`}
            />
            <ReferenceLine
              y={GOAL}
              stroke="var(--color-green-500)"
              strokeDasharray="4 4"
              label={{
                value: "Goal",
                position: "insideTopLeft",
                className: "fill-muted-foreground text-xs font-semibold",
              }}
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <span className="font-semibold tabular-nums">
                      {stepsFormat.format(Number(value))} steps
                    </span>
                  )}
                />
              }
            />
            <Line
              dataKey="steps"
              type="monotone"
              stroke="var(--color-steps)"
              strokeWidth={2.5}
              dot={{ r: 3.5, fill: "var(--color-steps)", strokeWidth: 0 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartGoal } from "@/components/charts/line-chart-goal"
```

```tsx
<LineChartGoal />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-goal.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"

const GOAL = 10000

const chartData = [
  { day: "Mon", steps: 8412 },
  { day: "Tue", steps: 10230 },
  { day: "Wed", steps: 6120 },
  { day: "Thu", steps: 12480 },
  { day: "Fri", steps: 9050 },
  { day: "Sat", steps: 14320 },
  { day: "Sun", steps: 4870 },
]

const chartConfig = {
  steps: { label: "Steps", color: "chart-4" },
} satisfies ChartConfig

function formatSteps(value: number) {
  try {
    return new Intl.NumberFormat("en-US").format(value)
  } catch {
    return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, ",")
  }
}

export function LineChartGoal() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Goal line</CardTitle>
        <CardDescription>A daily goal of 10,000 steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Goal line"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="day" tickMargin={8} interval={0} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              tickFormatter={(value: number) => `${value / 1000}k`}
            />
            <ReferenceLine
              y={GOAL}
              stroke="green-500"
              strokeDasharray="4 4"
              label="Goal"
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text className="font-semibold tabular-nums">
                      {formatSteps(Number(value))} steps
                    </Text>
                  )}
                />
              }
            />
            <Line
              dataKey="steps"
              type="monotone"
              strokeWidth={2.5}
              dot={{ r: 3.5 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartGoal.swift"
import Charts
import SwiftUI

private let goal = 10000.0

private let chartData: [(day: String, steps: Double)] = [
  ("Mon", 8412), ("Tue", 10230), ("Wed", 6120), ("Thu", 12480), ("Fri", 9050), ("Sat", 14320), ("Sun", 4870),
]

private let chartConfig: ChartConfig = [
  "steps": .init("Steps", color: EsuissColor.chart4),
]

public struct LineChartGoal: View {
  @State private var selection: Int?

  public init() {}

  public var body: some View {
    Card(.filled, size: .sm) {
      CardHeader("Goal line", description: "A daily goal of 10,000 steps")
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              RuleMark(y: .value("Goal", goal))
                .lineStyle(StrokeStyle(lineWidth: 1, dash: [4, 4]))
                .foregroundStyle(Palette.green500)
                .annotation(position: .top, alignment: .leading, spacing: 4) {
                  Text("Goal")
                    .scaledFont(TextStyle.xs, weight: .semibold)
                    .foregroundStyle(EsuissColor.mutedForeground)
                }
              ForEach(chartData.indices, id: \.self) { index in
                LineMark(x: .value("Day", index), y: .value("Steps", chartData[index].steps))
                  .interpolationMethod(.monotone)
                  .lineStyle(StrokeStyle(lineWidth: 2.5, lineCap: .round, lineJoin: .round))
                  .foregroundStyle(chartConfig.color("steps"))
                PointMark(x: .value("Day", index), y: .value("Steps", chartData[index].steps))
                  .symbolSize(selection == index ? 64 : 49)
                  .foregroundStyle(chartConfig.color("steps"))
              }
              .chartReveal(progress, x: 0...(chartData.count - 1))
            }
            .chartXScale(domain: 0...(chartData.count - 1), range: .plotDimension(padding: 12))
            .chartXAxis { ChartAxis.x(values: Array(chartData.indices)) { chartData[$0].day } }
            .chartYAxis { ChartAxis.y(count: 5) { "\(($0 / 1000).formatted())k" } }
            .chartTooltip(
              x: Array(chartData.indices),
              labels: chartData.map(\.day),
              selection: $selection,
              accessibilityLabel: "Goal line",
              items: { [ChartTooltipItem("steps", value: chartData[$0].steps)] }
            ) { payload in
              ChartTooltipContent(payload, hideIndicator: true) { item in
                Text("\(item.value, format: .number) steps")
                  .scaledFont(TextStyle.xs, weight: .semibold)
                  .monospacedDigit()
              }
            }
          }
        }
        .frame(height: 192)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartGoal.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartAxisOrientation
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartDot
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.LineChart
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Palette
import com.esuiss.ui.theme.Typography
import java.text.NumberFormat
import java.util.Locale

private const val GOAL = 10000.0

private class LineGoalRow(val day: String, val steps: Double)

private val chartData = listOf(
    LineGoalRow("Mon", 8412.0),
    LineGoalRow("Tue", 10230.0),
    LineGoalRow("Wed", 6120.0),
    LineGoalRow("Thu", 12480.0),
    LineGoalRow("Fri", 9050.0),
    LineGoalRow("Sat", 14320.0),
    LineGoalRow("Sun", 4870.0),
)

private val chartConfig = ChartConfig(
    "steps" to ChartConfigItem("Steps") { chart4 },
)

private fun thousands(value: Double): String {
    val k = value / 1000
    return if (k % 1.0 == 0.0) "${k.toLong()}k" else "${k}k"
}

@Composable
fun LineChartGoal(modifier: Modifier = Modifier) {
    val colors = EsuissTheme.colors
    val stepsFormat = NumberFormat.getNumberInstance(Locale.US)
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardHeader("Goal line", description = "A daily goal of 10,000 steps")
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(192.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 10.dp, right = 4.dp, bottom = 0.dp, left = 12.dp),
                    accessibilityLabel = "Goal line",
                ) {
                    CartesianGrid(strokeDasharray = listOf(2f, 4f))
                    XAxis(label = { it.day }, tickMargin = 8.dp, interval = 0)
                    YAxis(orientation = ChartAxisOrientation.Right, tickMargin = 6.dp, tickFormatter = ::thousands)
                    ReferenceLine(GOAL, stroke = Palette.green500, strokeDasharray = listOf(4f, 4f), label = "Goal")
                    ChartTooltip {
                        ChartTooltipContent(
                            hideIndicator = true,
                            formatter = { item ->
                                BasicText(
                                    "${stepsFormat.format(item.value)} steps",
                                    style = Typography.xs.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold, fontFeatureSettings = "tnum"),
                                )
                            },
                        )
                    }
                    Line(
                        "steps",
                        value = { it.steps },
                        curve = ChartCurve.Monotone,
                        strokeWidth = 2.5.dp,
                        dot = ChartDot(3.5.dp),
                    )
                }
            }
        }
    }
}
```

**React Native, Jetpack Compose**

Seven days of steps drawn as a monotone line with dots, a value axis in thousands on the right and a labeled dashed `ReferenceLine` at `GOAL`. The tooltip formats the count with thousands separators.

**React Native**

Replace `chartData` with your daily values and set `GOAL`. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-goal
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-goal
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-goal
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-goal --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-goal
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-goal --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-goal.tsx`:

- `uniwind/components/charts/line-chart-goal.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-goal.tsx`:

```tsx title="nativewind/components/charts/line-chart-goal.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"

const GOAL = 10000

const chartData = [
  { day: "Mon", steps: 8412 },
  { day: "Tue", steps: 10230 },
  { day: "Wed", steps: 6120 },
  { day: "Thu", steps: 12480 },
  { day: "Fri", steps: 9050 },
  { day: "Sat", steps: 14320 },
  { day: "Sun", steps: 4870 },
]

const chartConfig = {
  steps: { label: "Steps", color: "chart-4" },
} satisfies ChartConfig

function formatSteps(value: number) {
  try {
    return new Intl.NumberFormat("en-US").format(value)
  } catch {
    return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, ",")
  }
}

export function LineChartGoal() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Goal line</CardTitle>
        <CardDescription>A daily goal of 10,000 steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Goal line"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="day" tickMargin={8} interval={0} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              tickFormatter={(value: number) => `${value / 1000}k`}
            />
            <ReferenceLine
              y={GOAL}
              stroke="green-500"
              strokeDasharray="4 4"
              label="Goal"
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text className="font-semibold tabular-nums">
                      {formatSteps(Number(value))} steps
                    </Text>
                  )}
                />
              }
            />
            <Line
              dataKey="steps"
              type="monotone"
              strokeWidth={2.5}
              dot={{ r: 3.5 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text).

2. Copy and paste the following code into `components/charts/line-chart-goal.tsx`:

```tsx title="stylesheet/components/charts/line-chart-goal.tsx"
import { StyleSheet } from "react-native"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"

const GOAL = 10000

const chartData = [
  { day: "Mon", steps: 8412 },
  { day: "Tue", steps: 10230 },
  { day: "Wed", steps: 6120 },
  { day: "Thu", steps: 12480 },
  { day: "Fri", steps: 9050 },
  { day: "Sat", steps: 14320 },
  { day: "Sun", steps: 4870 },
]

const chartConfig = {
  steps: { label: "Steps", color: "chart-4" },
} satisfies ChartConfig

const styles = StyleSheet.create({
  strong: { fontWeight: "600", fontVariant: ["tabular-nums"] },
})

function formatSteps(value: number) {
  try {
    return new Intl.NumberFormat("en-US").format(value)
  } catch {
    return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, ",")
  }
}

export function LineChartGoal() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Goal line</CardTitle>
        <CardDescription>A daily goal of 10,000 steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Goal line"
          style={{ height: 192 }}
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="day" tickMargin={8} interval={0} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              tickFormatter={(value: number) => `${value / 1000}k`}
            />
            <ReferenceLine
              y={GOAL}
              stroke="green-500"
              strokeDasharray="4 4"
              label="Goal"
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideIndicator
                  formatter={(value) => (
                    <Text style={styles.strong}>
                      {formatSteps(Number(value))} steps
                    </Text>
                  )}
                />
              }
            />
            <Line
              dataKey="steps"
              type="monotone"
              strokeWidth={2.5}
              dot={{ r: 3.5 }}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartGoal.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartGoal.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartGoal } from "@/components/charts/line-chart-goal"
```

```tsx
<LineChartGoal />
```

**SwiftUI**

```swift
import SwiftUI

struct LineGoalExample: View {
  var body: some View {
    LineChartGoal()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartGoal

@Composable
fun LineGoalExample() {
    LineChartGoal()
}
```



## Line Chart Interactive

Monthly temperatures for several cities, with chips to show or hide each city and an average, high or low switch.

Source: https://suiss.app/ui/docs/charts/line-chart#interactive

**React**

**Example**

```tsx title="components/charts/line-chart-interactive.tsx"
"use client"

import * as React from "react"
import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  useActiveTooltipDataPoints,
  XAxis,
  YAxis,
} from "recharts"

import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"
import { Toggle } from "@/components/ui/toggle"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

type City = "istanbul" | "ankara" | "izmir" | "antalya" | "erzurum"

type Mode = "average" | "high" | "low"

const CITIES: Record<City, { average: number[]; spread: [number, number] }> = {
  istanbul: {
    average: [6, 6, 8, 12, 17, 22, 24, 24, 21, 16, 12, 8],
    spread: [6, 0.6],
  },
  ankara: {
    average: [0, 2, 6, 11, 16, 20, 24, 24, 19, 13, 7, 2],
    spread: [11, 1.6],
  },
  izmir: {
    average: [9, 10, 12, 16, 21, 26, 28, 28, 24, 19, 14, 10],
    spread: [9, 1],
  },
  antalya: {
    average: [10, 11, 13, 16, 21, 26, 29, 29, 25, 20, 15, 11],
    spread: [9, 0.9],
  },
  erzurum: {
    average: [-9, -8, -2, 6, 11, 15, 20, 20, 15, 8, 1, -6],
    spread: [12, 1.8],
  },
}

const CITY_KEYS = Object.keys(CITIES) as City[]

const MODES: Record<Mode, string> = {
  average: "Average",
  high: "High",
  low: "Low",
}

const MONTHS = Array.from(
  { length: 12 },
  (_, index) => new Date(2026, index, 1)
)
const shortMonth = new Intl.DateTimeFormat("en-US", { month: "short" })
const longMonth = new Intl.DateTimeFormat("en-US", { month: "long" })

const chartConfig = {
  istanbul: { label: "Istanbul", color: "var(--chart-1)" },
  ankara: { label: "Ankara", color: "var(--color-purple-500)" },
  izmir: { label: "Izmir", color: "var(--chart-2)" },
  antalya: { label: "Antalya", color: "var(--chart-4)" },
  erzurum: { label: "Erzurum", color: "var(--chart-3)" },
} satisfies ChartConfig

const TRANSITION = 650

function temperature(city: City, month: number, mode: Mode) {
  const { average, spread } = CITIES[city]
  const mean = average[month]
  if (mean === undefined) return Number.NaN
  if (mode === "average") return mean
  const season = Math.sin(((month - 0.5) / 12) * Math.PI)
  const range = spread[0] + spread[1] * 6 * season * season
  return mean + (mode === "high" ? range / 2 : -range / 2)
}

function ActiveMonth({
  onChange,
}: {
  onChange: (month: number | null) => void
}) {
  const points = useActiveTooltipDataPoints<{ index: number }>()
  const month = points?.[0]?.index ?? null

  React.useEffect(() => onChange(month), [month, onChange])

  return null
}

export function LineChartInteractive() {
  const [visible, setVisible] = React.useState<City[]>([
    "istanbul",
    "ankara",
    "antalya",
  ])
  const [mode, setMode] = React.useState<Mode>("average")
  const [month, setMonth] = React.useState<number | null>(null)
  const data = React.useMemo(
    () =>
      MONTHS.map((date, index) => ({
        index,
        month: shortMonth.format(date),
        ...Object.fromEntries(
          CITY_KEYS.map((city) => [
            city,
            Math.round(temperature(city, index, mode) * 10) / 10,
          ])
        ),
      })) as ({ index: number; month: string } & Record<City, number>)[],
    [mode]
  )
  const shown = CITY_KEYS.filter((city) => visible.includes(city))

  const toggle = (city: City, pressed: boolean) =>
    setVisible((current) => {
      if (pressed) return [...current, city]
      return current.length > 1
        ? current.filter((item) => item !== city)
        : current
    })

  return (
    <Card variant="filled" size="sm" className="[--card-spacing:--spacing(5)]">
      <CardHeader className="flex flex-wrap items-start justify-between gap-4">
        <div className="flex min-w-44 flex-1 flex-col gap-0.5">
          <p className="text-lg font-semibold">Monthly temperature</p>
          <p className="text-sm text-muted-foreground">
            {MODES[mode]} · °C · long-term
          </p>
        </div>
        <ToggleGroup
          spacing={0}
          value={[mode]}
          onValueChange={(value: string[]) => {
            if (value[0]) setMode(value[0] as Mode)
          }}
          aria-label="Temperature"
        >
          {(Object.keys(MODES) as Mode[]).map((key) => (
            <ToggleGroupItem key={key} value={key} size="sm">
              {MODES[key]}
            </ToggleGroupItem>
          ))}
        </ToggleGroup>
      </CardHeader>
      <CardContent className="flex flex-col gap-4">
        <div className="flex flex-wrap gap-2" role="group" aria-label="Cities">
          {CITY_KEYS.map((city) => (
            <Toggle
              key={city}
              size="sm"
              pressed={visible.includes(city)}
              onPressedChange={(pressed) => toggle(city, pressed)}
              style={
                { "--chip": chartConfig[city].color } as React.CSSProperties
              }
              className="gap-1.5 bg-secondary font-semibold text-secondary-foreground aria-pressed:bg-[color-mix(in_oklab,var(--chip)_16%,transparent)] aria-pressed:text-foreground aria-pressed:hover:bg-[color-mix(in_oklab,var(--chip)_22%,transparent)] aria-pressed:hover:text-foreground aria-pressed:active:bg-[color-mix(in_oklab,var(--chip)_28%,transparent)]"
            >
              <span
                aria-hidden
                className="size-2 rounded-full bg-border transition-colors in-aria-pressed:bg-(--chip)"
              />
              {chartConfig[city].label}
            </Toggle>
          ))}
        </div>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-72 w-full"
        >
          <LineChart
            accessibilityLayer
            data={data}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              minTickGap={8}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              domain={[-20, 40]}
              ticks={[-20, -10, 0, 10, 20, 30, 40]}
              allowDataOverflow
              tickFormatter={(value: number) => `${value}°`}
            />
            <ReferenceLine y={0} stroke="var(--input)" />
            <ChartTooltip
              content={({ active, label, payload }) => (
                <ChartTooltipContent
                  active={active}
                  label={label}
                  payload={payload}
                  indicator="line"
                  labelFormatter={(_, items) =>
                    longMonth.format(MONTHS[items[0]?.payload.index ?? 0])
                  }
                  formatter={(value, name) => (
                    <div className="flex w-full items-center gap-2">
                      <span
                        className="h-3 w-0.75 shrink-0 rounded-full bg-(--swatch)"
                        style={
                          {
                            "--swatch": chartConfig[name as City].color,
                          } as React.CSSProperties
                        }
                      />
                      <span className="flex-1 text-muted-foreground">
                        {chartConfig[name as City].label}
                      </span>
                      <span className="font-semibold tabular-nums">
                        {value}°
                      </span>
                    </div>
                  )}
                />
              )}
            />
            {shown.map((city) => (
              <Line
                key={city}
                dataKey={city}
                type="monotone"
                stroke={`var(--color-${city})`}
                strokeWidth={2.5}
                dot={false}
                activeDot={{
                  r: 5,
                  strokeWidth: 2,
                  stroke: "var(--muted)",
                }}
                animationDuration={TRANSITION}
                animationEasing="ease-in-out"
                pathLength={1}
                className="[&_.recharts-line-curve]:[stroke-dasharray:1] [&_.recharts-line-curve]:transition-[stroke-dashoffset] [&_.recharts-line-curve]:duration-750 [&_.recharts-line-curve]:ease-[cubic-bezier(0.45,0,0.2,1)] [&_.recharts-line-curve]:starting:[stroke-dashoffset:1] motion-reduce:[&_.recharts-line-curve]:transition-none"
              />
            ))}
            <ActiveMonth onChange={setMonth} />
          </LineChart>
        </ChartContainer>
        <dl className="grid grid-cols-[repeat(auto-fit,minmax(8.5rem,1fr))] gap-3">
          {shown.map((city) => {
            const temperatures = data.map((item) => item[city])
            const highlighted = month === null ? undefined : temperatures[month]
            return (
              <div key={city} className="flex flex-col gap-0.5">
                <dt className="flex items-center gap-1.5 text-sm text-muted-foreground">
                  <span
                    className="size-2 shrink-0 rounded-full bg-(--swatch)"
                    style={
                      {
                        "--swatch": chartConfig[city].color,
                      } as React.CSSProperties
                    }
                  />
                  {chartConfig[city].label}
                </dt>
                <dd className="text-base font-semibold tabular-nums">
                  {month === null || highlighted === undefined
                    ? `${Math.round(Math.min(...temperatures))}° / ${Math.round(Math.max(...temperatures))}°`
                    : `${Math.round(highlighted)}° · ${longMonth.format(MONTHS[month])}`}
                </dd>
              </div>
            )
          })}
        </dl>
      </CardContent>
    </Card>
  )
}
```

Monthly temperatures for several cities with chips to show or hide each city and a switch between average, high and low. A row of stats under the chart shows each city's range and follows the cursor month. Use it as a pattern for comparing many series where readers pick which ones to see.

Replace `CITIES` with your series and add a label and color for each to `chartConfig`; the `visible` state sets which ones start visible. The high and low modes come from a demo formula, so replace `temperature` with real values and fit the fixed value axis `domain` to your range, since values outside it are clipped. The last visible city can't be hidden, and new lines draw in with an animation that is skipped when reduced motion is preferred.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-interactive
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-interactive
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Toggle](https://suiss.app/ui/docs/components/toggle), [Toggle Group](https://suiss.app/ui/docs/components/toggle-group).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-interactive.tsx"
"use client"

import * as React from "react"
import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  useActiveTooltipDataPoints,
  XAxis,
  YAxis,
} from "recharts"

import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"
import { Toggle } from "@/components/ui/toggle"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

type City = "istanbul" | "ankara" | "izmir" | "antalya" | "erzurum"

type Mode = "average" | "high" | "low"

const CITIES: Record<City, { average: number[]; spread: [number, number] }> = {
  istanbul: {
    average: [6, 6, 8, 12, 17, 22, 24, 24, 21, 16, 12, 8],
    spread: [6, 0.6],
  },
  ankara: {
    average: [0, 2, 6, 11, 16, 20, 24, 24, 19, 13, 7, 2],
    spread: [11, 1.6],
  },
  izmir: {
    average: [9, 10, 12, 16, 21, 26, 28, 28, 24, 19, 14, 10],
    spread: [9, 1],
  },
  antalya: {
    average: [10, 11, 13, 16, 21, 26, 29, 29, 25, 20, 15, 11],
    spread: [9, 0.9],
  },
  erzurum: {
    average: [-9, -8, -2, 6, 11, 15, 20, 20, 15, 8, 1, -6],
    spread: [12, 1.8],
  },
}

const CITY_KEYS = Object.keys(CITIES) as City[]

const MODES: Record<Mode, string> = {
  average: "Average",
  high: "High",
  low: "Low",
}

const MONTHS = Array.from(
  { length: 12 },
  (_, index) => new Date(2026, index, 1)
)
const shortMonth = new Intl.DateTimeFormat("en-US", { month: "short" })
const longMonth = new Intl.DateTimeFormat("en-US", { month: "long" })

const chartConfig = {
  istanbul: { label: "Istanbul", color: "var(--chart-1)" },
  ankara: { label: "Ankara", color: "var(--color-purple-500)" },
  izmir: { label: "Izmir", color: "var(--chart-2)" },
  antalya: { label: "Antalya", color: "var(--chart-4)" },
  erzurum: { label: "Erzurum", color: "var(--chart-3)" },
} satisfies ChartConfig

const TRANSITION = 650

function temperature(city: City, month: number, mode: Mode) {
  const { average, spread } = CITIES[city]
  const mean = average[month]
  if (mean === undefined) return Number.NaN
  if (mode === "average") return mean
  const season = Math.sin(((month - 0.5) / 12) * Math.PI)
  const range = spread[0] + spread[1] * 6 * season * season
  return mean + (mode === "high" ? range / 2 : -range / 2)
}

function ActiveMonth({
  onChange,
}: {
  onChange: (month: number | null) => void
}) {
  const points = useActiveTooltipDataPoints<{ index: number }>()
  const month = points?.[0]?.index ?? null

  React.useEffect(() => onChange(month), [month, onChange])

  return null
}

export function LineChartInteractive() {
  const [visible, setVisible] = React.useState<City[]>([
    "istanbul",
    "ankara",
    "antalya",
  ])
  const [mode, setMode] = React.useState<Mode>("average")
  const [month, setMonth] = React.useState<number | null>(null)
  const data = React.useMemo(
    () =>
      MONTHS.map((date, index) => ({
        index,
        month: shortMonth.format(date),
        ...Object.fromEntries(
          CITY_KEYS.map((city) => [
            city,
            Math.round(temperature(city, index, mode) * 10) / 10,
          ])
        ),
      })) as ({ index: number; month: string } & Record<City, number>)[],
    [mode]
  )
  const shown = CITY_KEYS.filter((city) => visible.includes(city))

  const toggle = (city: City, pressed: boolean) =>
    setVisible((current) => {
      if (pressed) return [...current, city]
      return current.length > 1
        ? current.filter((item) => item !== city)
        : current
    })

  return (
    <Card variant="filled" size="sm" className="[--card-spacing:--spacing(5)]">
      <CardHeader className="flex flex-wrap items-start justify-between gap-4">
        <div className="flex min-w-44 flex-1 flex-col gap-0.5">
          <p className="text-lg font-semibold">Monthly temperature</p>
          <p className="text-sm text-muted-foreground">
            {MODES[mode]} · °C · long-term
          </p>
        </div>
        <ToggleGroup
          spacing={0}
          value={[mode]}
          onValueChange={(value: string[]) => {
            if (value[0]) setMode(value[0] as Mode)
          }}
          aria-label="Temperature"
        >
          {(Object.keys(MODES) as Mode[]).map((key) => (
            <ToggleGroupItem key={key} value={key} size="sm">
              {MODES[key]}
            </ToggleGroupItem>
          ))}
        </ToggleGroup>
      </CardHeader>
      <CardContent className="flex flex-col gap-4">
        <div className="flex flex-wrap gap-2" role="group" aria-label="Cities">
          {CITY_KEYS.map((city) => (
            <Toggle
              key={city}
              size="sm"
              pressed={visible.includes(city)}
              onPressedChange={(pressed) => toggle(city, pressed)}
              style={
                { "--chip": chartConfig[city].color } as React.CSSProperties
              }
              className="gap-1.5 bg-secondary font-semibold text-secondary-foreground aria-pressed:bg-[color-mix(in_oklab,var(--chip)_16%,transparent)] aria-pressed:text-foreground aria-pressed:hover:bg-[color-mix(in_oklab,var(--chip)_22%,transparent)] aria-pressed:hover:text-foreground aria-pressed:active:bg-[color-mix(in_oklab,var(--chip)_28%,transparent)]"
            >
              <span
                aria-hidden
                className="size-2 rounded-full bg-border transition-colors in-aria-pressed:bg-(--chip)"
              />
              {chartConfig[city].label}
            </Toggle>
          ))}
        </div>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-72 w-full"
        >
          <LineChart
            accessibilityLayer
            data={data}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              minTickGap={8}
            />
            <YAxis
              orientation="right"
              tickLine={false}
              axisLine={false}
              tickMargin={6}
              width="auto"
              domain={[-20, 40]}
              ticks={[-20, -10, 0, 10, 20, 30, 40]}
              allowDataOverflow
              tickFormatter={(value: number) => `${value}°`}
            />
            <ReferenceLine y={0} stroke="var(--input)" />
            <ChartTooltip
              content={({ active, label, payload }) => (
                <ChartTooltipContent
                  active={active}
                  label={label}
                  payload={payload}
                  indicator="line"
                  labelFormatter={(_, items) =>
                    longMonth.format(MONTHS[items[0]?.payload.index ?? 0])
                  }
                  formatter={(value, name) => (
                    <div className="flex w-full items-center gap-2">
                      <span
                        className="h-3 w-0.75 shrink-0 rounded-full bg-(--swatch)"
                        style={
                          {
                            "--swatch": chartConfig[name as City].color,
                          } as React.CSSProperties
                        }
                      />
                      <span className="flex-1 text-muted-foreground">
                        {chartConfig[name as City].label}
                      </span>
                      <span className="font-semibold tabular-nums">
                        {value}°
                      </span>
                    </div>
                  )}
                />
              )}
            />
            {shown.map((city) => (
              <Line
                key={city}
                dataKey={city}
                type="monotone"
                stroke={`var(--color-${city})`}
                strokeWidth={2.5}
                dot={false}
                activeDot={{
                  r: 5,
                  strokeWidth: 2,
                  stroke: "var(--muted)",
                }}
                animationDuration={TRANSITION}
                animationEasing="ease-in-out"
                pathLength={1}
                className="[&_.recharts-line-curve]:[stroke-dasharray:1] [&_.recharts-line-curve]:transition-[stroke-dashoffset] [&_.recharts-line-curve]:duration-750 [&_.recharts-line-curve]:ease-[cubic-bezier(0.45,0,0.2,1)] [&_.recharts-line-curve]:starting:[stroke-dashoffset:1] motion-reduce:[&_.recharts-line-curve]:transition-none"
              />
            ))}
            <ActiveMonth onChange={setMonth} />
          </LineChart>
        </ChartContainer>
        <dl className="grid grid-cols-[repeat(auto-fit,minmax(8.5rem,1fr))] gap-3">
          {shown.map((city) => {
            const temperatures = data.map((item) => item[city])
            const highlighted = month === null ? undefined : temperatures[month]
            return (
              <div key={city} className="flex flex-col gap-0.5">
                <dt className="flex items-center gap-1.5 text-sm text-muted-foreground">
                  <span
                    className="size-2 shrink-0 rounded-full bg-(--swatch)"
                    style={
                      {
                        "--swatch": chartConfig[city].color,
                      } as React.CSSProperties
                    }
                  />
                  {chartConfig[city].label}
                </dt>
                <dd className="text-base font-semibold tabular-nums">
                  {month === null || highlighted === undefined
                    ? `${Math.round(Math.min(...temperatures))}° / ${Math.round(Math.max(...temperatures))}°`
                    : `${Math.round(highlighted)}° · ${longMonth.format(MONTHS[month])}`}
                </dd>
              </div>
            )
          })}
        </dl>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartInteractive } from "@/components/charts/line-chart-interactive"
```

```tsx
<LineChartInteractive />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-interactive.tsx"
import { cn } from "cn"
import * as React from "react"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"
import { Toggle } from "@/components/ui/toggle"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

type City = "istanbul" | "ankara" | "izmir" | "antalya" | "erzurum"

type Mode = "average" | "high" | "low"

const CITIES: Record<City, { average: number[]; spread: [number, number] }> = {
  istanbul: {
    average: [6, 6, 8, 12, 17, 22, 24, 24, 21, 16, 12, 8],
    spread: [6, 0.6],
  },
  ankara: {
    average: [0, 2, 6, 11, 16, 20, 24, 24, 19, 13, 7, 2],
    spread: [11, 1.6],
  },
  izmir: {
    average: [9, 10, 12, 16, 21, 26, 28, 28, 24, 19, 14, 10],
    spread: [9, 1],
  },
  antalya: {
    average: [10, 11, 13, 16, 21, 26, 29, 29, 25, 20, 15, 11],
    spread: [9, 0.9],
  },
  erzurum: {
    average: [-9, -8, -2, 6, 11, 15, 20, 20, 15, 8, 1, -6],
    spread: [12, 1.8],
  },
}

const CITY_KEYS = Object.keys(CITIES) as City[]

const MODES: Record<Mode, string> = {
  average: "Average",
  high: "High",
  low: "Low",
}

const MONTHS = [
  "January",
  "February",
  "March",
  "April",
  "May",
  "June",
  "July",
  "August",
  "September",
  "October",
  "November",
  "December",
]

const chartConfig = {
  istanbul: { label: "Istanbul", color: "chart-1" },
  ankara: { label: "Ankara", color: "purple-500" },
  izmir: { label: "Izmir", color: "chart-2" },
  antalya: { label: "Antalya", color: "chart-4" },
  erzurum: { label: "Erzurum", color: "chart-3" },
} satisfies ChartConfig

const SWATCH: Record<City, { dot: string; chip: string }> = {
  istanbul: { dot: "bg-blue-500", chip: "bg-blue-500/15 active:opacity-80" },
  ankara: { dot: "bg-purple-500", chip: "bg-purple-500/15 active:opacity-80" },
  izmir: { dot: "bg-teal-500", chip: "bg-teal-500/15 active:opacity-80" },
  antalya: { dot: "bg-orange-500", chip: "bg-orange-500/15 active:opacity-80" },
  erzurum: { dot: "bg-indigo-500", chip: "bg-indigo-500/15 active:opacity-80" },
}

function temperature(city: City, month: number, mode: Mode) {
  const { average, spread } = CITIES[city]
  const mean = average[month]
  if (mean === undefined) return Number.NaN
  if (mode === "average") return mean
  const season = Math.sin(((month - 0.5) / 12) * Math.PI)
  const range = spread[0] + spread[1] * 6 * season * season
  return mean + (mode === "high" ? range / 2 : -range / 2)
}

export function LineChartInteractive() {
  const [visible, setVisible] = React.useState<City[]>([
    "istanbul",
    "ankara",
    "antalya",
  ])
  const [mode, setMode] = React.useState<Mode>("average")
  const [month, setMonth] = React.useState<number | null>(null)
  const data = React.useMemo(
    () =>
      MONTHS.map((name, index) => ({
        index,
        month: name.slice(0, 3),
        ...Object.fromEntries(
          CITY_KEYS.map((city) => [
            city,
            Math.round(temperature(city, index, mode) * 10) / 10,
          ])
        ),
      })) as ({ index: number; month: string } & Record<City, number>)[],
    [mode]
  )
  const shown = CITY_KEYS.filter((city) => visible.includes(city))

  const toggle = (city: City, pressed: boolean) =>
    setVisible((current) => {
      if (pressed) return [...current, city]
      return current.length > 1
        ? current.filter((item) => item !== city)
        : current
    })

  return (
    <Card variant="filled" size="sm">
      <CardHeader className="flex-row flex-wrap items-start justify-between gap-4">
        <View className="min-w-44 grow gap-0.5">
          <Text className="text-lg font-semibold">Monthly temperature</Text>
          <Text className="text-sm text-muted-foreground">
            {MODES[mode]} · °C · long-term
          </Text>
        </View>
        <ToggleGroup
          spacing={0}
          value={[mode]}
          onValueChange={(value) => {
            if (value[0]) setMode(value[0] as Mode)
          }}
          accessibilityLabel="Temperature"
        >
          {(Object.keys(MODES) as Mode[]).map((key) => (
            <ToggleGroupItem key={key} value={key} size="sm">
              <Text>{MODES[key]}</Text>
            </ToggleGroupItem>
          ))}
        </ToggleGroup>
      </CardHeader>
      <CardContent className="gap-4">
        <View
          className="flex-row flex-wrap gap-2"
          role="group"
          accessibilityLabel="Cities"
        >
          {CITY_KEYS.map((city) => (
            <Toggle
              key={city}
              size="sm"
              pressed={visible.includes(city)}
              onPressedChange={(pressed) => toggle(city, pressed)}
              className={(state) =>
                cn(
                  "gap-1.5",
                  state.pressed
                    ? SWATCH[city].chip
                    : "bg-secondary active:opacity-80"
                )
              }
            >
              <View
                className={cn(
                  "size-2 rounded-full",
                  visible.includes(city) ? SWATCH[city].dot : "bg-border"
                )}
              />
              <Text className="text-sm font-semibold text-foreground">
                {chartConfig[city].label}
              </Text>
            </Toggle>
          ))}
        </View>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Monthly temperature"
          className="h-72 w-full"
        >
          <LineChart
            data={data}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
            onActiveIndexChange={setMonth}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} minTickGap={8} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[-20, 40]}
              ticks={[-20, -10, 0, 10, 20, 30, 40]}
              tickFormatter={(value: number) => `${value}°`}
            />
            <ReferenceLine y={0} stroke="input" />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  indicator="line"
                  labelFormatter={(_, items) =>
                    MONTHS[Number(items[0]?.payload.index ?? 0)]
                  }
                  formatter={(value, name) => (
                    <View className="w-full flex-row items-center gap-2">
                      <View
                        className={cn(
                          "h-3 w-0.75 shrink-0 rounded-full",
                          SWATCH[name as City].dot
                        )}
                      />
                      <Text className="grow text-muted-foreground">
                        {chartConfig[name as City].label}
                      </Text>
                      <Text className="font-semibold tabular-nums">
                        {String(value)}°
                      </Text>
                    </View>
                  )}
                />
              }
            />
            {shown.map((city) => (
              <Line
                animationDuration={650}
                animationEasing="ease-in-out"
                key={city}
                dataKey={city}
                type="monotone"
                strokeWidth={2.5}
                activeDot={{
                  r: 5,
                  strokeWidth: 2,
                  stroke: "muted",
                }}
              />
            ))}
          </LineChart>
        </ChartContainer>
        <View className="flex-row flex-wrap gap-3">
          {shown.map((city) => {
            const temperatures = data.map((item) => item[city])
            const highlighted = month === null ? undefined : temperatures[month]
            return (
              <View key={city} className="min-w-34 grow basis-0 gap-0.5">
                <View className="flex-row items-center gap-1.5">
                  <View
                    className={cn(
                      "size-2 shrink-0 rounded-full",
                      SWATCH[city].dot
                    )}
                  />
                  <Text className="text-sm text-muted-foreground">
                    {chartConfig[city].label}
                  </Text>
                </View>
                <Text className="text-base font-semibold tabular-nums">
                  {month === null || highlighted === undefined
                    ? `${Math.round(Math.min(...temperatures))}° / ${Math.round(Math.max(...temperatures))}°`
                    : `${Math.round(highlighted)}° · ${MONTHS[month]}`}
                </Text>
              </View>
            )
          })}
        </View>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartInteractive.swift"
import Charts
import SwiftUI

private enum City: String, CaseIterable {
  case istanbul, ankara, izmir, antalya, erzurum

  var average: [Double] {
    switch self {
    case .istanbul: [6, 6, 8, 12, 17, 22, 24, 24, 21, 16, 12, 8]
    case .ankara: [0, 2, 6, 11, 16, 20, 24, 24, 19, 13, 7, 2]
    case .izmir: [9, 10, 12, 16, 21, 26, 28, 28, 24, 19, 14, 10]
    case .antalya: [10, 11, 13, 16, 21, 26, 29, 29, 25, 20, 15, 11]
    case .erzurum: [-9, -8, -2, 6, 11, 15, 20, 20, 15, 8, 1, -6]
    }
  }

  var spread: (Double, Double) {
    switch self {
    case .istanbul: (6, 0.6)
    case .ankara: (11, 1.6)
    case .izmir: (9, 1)
    case .antalya: (9, 0.9)
    case .erzurum: (12, 1.8)
    }
  }
}

private enum Mode: String, CaseIterable {
  case average, high, low

  var title: String {
    switch self {
    case .average: "Average"
    case .high: "High"
    case .low: "Low"
    }
  }
}

private let chartConfig: ChartConfig = [
  "istanbul": .init("Istanbul", color: EsuissColor.chart1),
  "ankara": .init("Ankara", color: Palette.purple500),
  "izmir": .init("Izmir", color: EsuissColor.chart2),
  "antalya": .init("Antalya", color: EsuissColor.chart4),
  "erzurum": .init("Erzurum", color: EsuissColor.chart3),
]

private func temperature(_ city: City, month: Int, mode: Mode) -> Double {
  let mean = city.average[month]
  if mode == .average { return mean }
  let season = sin((Double(month) - 0.5) / 12 * .pi)
  let range = city.spread.0 + city.spread.1 * 6 * season * season
  let value = mean + (mode == .high ? range / 2 : -range / 2)
  return (value * 10).rounded() / 10
}

public struct LineChartInteractive: View {
  @State private var visible: Set<City> = [.istanbul, .ankara, .antalya]
  @State private var mode: Mode = .average
  @State private var selection: Int?
  @Environment(\.locale) private var locale
  @Environment(\.accessibilityReduceMotion) private var reduceMotion

  public init() {}

  private var months: [Date] {
    (0..<12).compactMap { Calendar(identifier: .gregorian).date(from: DateComponents(year: 2026, month: $0 + 1, day: 1)) }
  }

  private func shortMonth(_ index: Int) -> String {
    months[index].formatted(.dateTime.month(.abbreviated).locale(locale))
  }

  private func longMonth(_ index: Int) -> String {
    months[index].formatted(.dateTime.month(.wide).locale(locale))
  }

  private var shown: [City] {
    City.allCases.filter { visible.contains($0) }
  }

  private var modeBinding: Binding<Mode?> {
    Binding(get: { mode }, set: { if let value = $0 { mode = value } })
  }

  private func toggle(_ city: City) {
    if visible.contains(city) {
      if visible.count > 1 { visible.remove(city) }
    } else {
      visible.insert(city)
    }
  }

  public var body: some View {
    Card(.filled, size: .sm) {
      VStack(alignment: .leading, spacing: 16) {
        VStack(alignment: .leading, spacing: 2) {
          Text("Monthly temperature")
            .textStyle(.lg, weight: .semibold)
          Text("\(mode.title) · °C · long-term")
            .textStyle(.sm)
            .foregroundStyle(EsuissColor.mutedForeground)
        }
        ToggleGroup(selection: modeBinding, size: .sm, spacing: 0) {
          ForEach(Mode.allCases, id: \.self) { item in
            ToggleGroupItem(LocalizedStringKey(item.title), value: item)
          }
        }
        .accessibilityLabel("Temperature")
      }
      .padding(.horizontal, 16)
      CardContent {
        VStack(alignment: .leading, spacing: 16) {
          ChartLegendLayout(horizontalSpacing: 8, verticalSpacing: 8, centered: false) {
            ForEach(City.allCases, id: \.self) { city in
              CityChip(
                label: chartConfig.label(city.rawValue),
                color: chartConfig.color(city.rawValue),
                isOn: visible.contains(city)
              ) {
                toggle(city)
              }
            }
          }
          .accessibilityElement(children: .contain)
          .accessibilityLabel("Cities")
          chart
          LazyVGrid(columns: [GridItem(.adaptive(minimum: 136), spacing: 12, alignment: .leading)], alignment: .leading, spacing: 12) {
            ForEach(shown, id: \.self) { city in
              stat(city)
            }
          }
        }
      }
    }
    .hapticFeedback(.selection, trigger: visible)
  }

  private var chart: some View {
    ChartContainer(config: chartConfig) {
      ChartAnimator(animationDuration: 650, animationEasing: .easeInOut) { progress in
        Chart {
          RuleMark(y: .value("Zero", 0))
            .lineStyle(StrokeStyle(lineWidth: 1))
            .foregroundStyle(EsuissColor.input)
          ForEach(shown, id: \.self) { city in
            ForEach(0..<12, id: \.self) { month in
              LineMark(
                x: .value("Month", month),
                y: .value("Temperature", temperature(city, month: month, mode: mode)),
                series: .value("City", city.rawValue)
              )
              .interpolationMethod(.monotone)
              .lineStyle(StrokeStyle(lineWidth: 2.5, lineCap: .round, lineJoin: .round))
              .foregroundStyle(chartConfig.color(city.rawValue))
            }
            if let selection {
              PointMark(x: .value("Month", selection), y: .value("Temperature", temperature(city, month: selection, mode: mode)))
                .symbol {
                  Circle()
                    .fill(chartConfig.color(city.rawValue))
                    .stroke(EsuissColor.muted, lineWidth: 2)
                    .frame(width: 12, height: 12)
                }
            }
          }
          .chartReveal(progress, x: 0...11)
        }
        .chartXScale(domain: 0...11, range: .plotDimension(padding: 8))
        .chartYScale(domain: -20...40)
        .chartXAxis { ChartAxis.x(values: [0, 2, 4, 6, 8, 10]) { shortMonth($0) } }
        .chartYAxis { ChartAxis.y(values: [-20.0, -10, 0, 10, 20, 30, 40]) { "\(Int($0))°" } }
        .animation(reduceMotion ? nil : .easeInOut(duration: 0.65), value: mode)
        .animation(reduceMotion ? nil : .easeInOut(duration: 0.3), value: visible)
        .chartTooltip(
          x: Array(0..<12),
          labels: (0..<12).map(longMonth),
          selection: $selection,
          accessibilityLabel: "Monthly temperature",
          items: { month in
            shown.map { ChartTooltipItem($0.rawValue, value: temperature($0, month: month, mode: mode)) }
          }
        ) { payload in
          ChartTooltipContent(payload, indicator: .line) { payload in
            Text(verbatim: longMonth(payload.index))
          } formatter: { item in
            Capsule()
              .fill(chartConfig.color(item.key))
              .frame(width: 3, height: 12)
            Text(LocalizedStringKey(chartConfig.label(item.key)))
              .foregroundStyle(EsuissColor.mutedForeground)
              .frame(maxWidth: .infinity, alignment: .leading)
            Text("\(item.value, format: .number)°")
              .scaledFont(TextStyle.xs, weight: .semibold)
              .monospacedDigit()
          }
        }
      }
    }
    .frame(height: 288)
  }

  private func stat(_ city: City) -> some View {
    let temperatures = (0..<12).map { temperature(city, month: $0, mode: mode) }
    let value: String
    if let selection {
      value = "\(Int(temperatures[selection].rounded()))° · \(longMonth(selection))"
    } else {
      value = "\(Int((temperatures.min() ?? 0).rounded()))° / \(Int((temperatures.max() ?? 0).rounded()))°"
    }
    return VStack(alignment: .leading, spacing: 2) {
      HStack(spacing: 6) {
        Circle()
          .fill(chartConfig.color(city.rawValue))
          .frame(width: 8, height: 8)
        Text(LocalizedStringKey(chartConfig.label(city.rawValue)))
          .textStyle(.sm)
          .foregroundStyle(EsuissColor.mutedForeground)
      }
      Text(verbatim: value)
        .textStyle(.base, weight: .semibold)
        .monospacedDigit()
    }
    .accessibilityElement(children: .combine)
  }
}

private struct CityChip: View {
  let label: String
  let color: Color
  let isOn: Bool
  let action: () -> Void

  var body: some View {
    Button(action: action) {
      HStack(spacing: 6) {
        Circle()
          .fill(isOn ? color : EsuissColor.border)
          .frame(width: 8, height: 8)
        Text(LocalizedStringKey(label))
          .textStyle(.sm, weight: .semibold)
          .foregroundStyle(EsuissColor.foreground)
      }
      .padding(.horizontal, 12)
      .frame(height: 32)
    }
    .buttonStyle(CityChipStyle(color: color, isOn: isOn))
    .accessibilityAddTraits(isOn ? .isSelected : [])
  }
}

private struct CityChipStyle: ButtonStyle {
  let color: Color
  let isOn: Bool

  func makeBody(configuration: Configuration) -> some View {
    configuration.label
      .background(isOn ? color.opacity(0.16) : EsuissColor.secondary, in: RoundedRectangle(cornerRadius: Radius.lg, style: .continuous))
      .opacity(configuration.isPressed ? 0.8 : 1)
      .contentShape(RoundedRectangle(cornerRadius: Radius.lg, style: .continuous))
  }
}
```

```kt title="kotlin/charts/LineChartInteractive.kt"
package com.esuiss.ui.charts

import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartAxisOrientation
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartDot
import com.esuiss.ui.components.ChartEasing
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.ChartTooltipIndicator
import com.esuiss.ui.components.LineChart
import com.esuiss.ui.components.ToggleGroup
import com.esuiss.ui.components.ToggleGroupItem
import com.esuiss.ui.components.ToggleSize
import com.esuiss.ui.components.chartColor
import com.esuiss.ui.components.rememberHaptics
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Palette
import com.esuiss.ui.theme.Radius
import com.esuiss.ui.theme.Typography
import kotlin.math.PI
import kotlin.math.roundToInt
import kotlin.math.sin

private class CityClimate(val average: List<Double>, val spread: Pair<Double, Double>)

private val cities = linkedMapOf(
    "istanbul" to CityClimate(listOf(6.0, 6.0, 8.0, 12.0, 17.0, 22.0, 24.0, 24.0, 21.0, 16.0, 12.0, 8.0), 6.0 to 0.6),
    "ankara" to CityClimate(listOf(0.0, 2.0, 6.0, 11.0, 16.0, 20.0, 24.0, 24.0, 19.0, 13.0, 7.0, 2.0), 11.0 to 1.6),
    "izmir" to CityClimate(listOf(9.0, 10.0, 12.0, 16.0, 21.0, 26.0, 28.0, 28.0, 24.0, 19.0, 14.0, 10.0), 9.0 to 1.0),
    "antalya" to CityClimate(listOf(10.0, 11.0, 13.0, 16.0, 21.0, 26.0, 29.0, 29.0, 25.0, 20.0, 15.0, 11.0), 9.0 to 0.9),
    "erzurum" to CityClimate(listOf(-9.0, -8.0, -2.0, 6.0, 11.0, 15.0, 20.0, 20.0, 15.0, 8.0, 1.0, -6.0), 12.0 to 1.8),
)

private val modes = linkedMapOf("average" to "Average", "high" to "High", "low" to "Low")

private val shortMonths = listOf("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")

private val longMonths = listOf(
    "January", "February", "March", "April", "May", "June",
    "July", "August", "September", "October", "November", "December",
)

private val chartConfig = ChartConfig(
    "istanbul" to ChartConfigItem("Istanbul") { chart1 },
    "ankara" to ChartConfigItem("Ankara") { Palette.purple500 },
    "izmir" to ChartConfigItem("Izmir") { chart2 },
    "antalya" to ChartConfigItem("Antalya") { chart4 },
    "erzurum" to ChartConfigItem("Erzurum") { chart3 },
)

private class TemperatureRow(val index: Int, val month: String, val values: Map<String, Double>)

private fun temperature(city: String, month: Int, mode: String): Double {
    val climate = cities.getValue(city)
    val mean = climate.average[month]
    if (mode == "average") return mean
    val season = sin((month - 0.5) / 12 * PI)
    val range = climate.spread.first + climate.spread.second * 6 * season * season
    return mean + if (mode == "high") range / 2 else -range / 2
}

private fun degrees(value: Double): String = if (value % 1.0 == 0.0) value.toLong().toString() else value.toString()

@Composable
private fun CityToggle(label: String, color: Color, pressed: Boolean, onPressedChange: (Boolean) -> Unit) {
    val colors = EsuissTheme.colors
    val haptics = rememberHaptics()
    val background by animateColorAsState(if (pressed) color.copy(alpha = 0.16f) else colors.secondary, label = "background")
    val dot by animateColorAsState(if (pressed) color else colors.border, label = "dot")
    Row(
        modifier = Modifier
            .height(32.dp)
            .background(background, RoundedCornerShape(Radius.lg))
            .toggleable(pressed, role = Role.Checkbox) {
                haptics.toggle(it)
                onPressedChange(it)
            }
            .padding(horizontal = 12.dp),
        horizontalArrangement = Arrangement.spacedBy(6.dp),
        verticalAlignment = Alignment.CenterVertically,
    ) {
        Box(
            Modifier
                .size(8.dp)
                .background(dot, CircleShape),
        )
        BasicText(label, style = Typography.sm.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold))
    }
}

@Composable
fun LineChartInteractive(modifier: Modifier = Modifier) {
    val colors = EsuissTheme.colors
    var visible by remember { mutableStateOf(listOf("istanbul", "ankara", "antalya")) }
    var mode by remember { mutableStateOf("average") }
    var month by remember { mutableStateOf<Int?>(null) }
    val data = remember(mode) {
        shortMonths.mapIndexed { index, name ->
            TemperatureRow(
                index,
                name,
                cities.keys.associateWith { city -> (temperature(city, index, mode) * 10).roundToInt() / 10.0 },
            )
        }
    }
    val shown = cities.keys.filter { it in visible }
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardContent {
            Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
                Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
                    BasicText("Monthly temperature", style = Typography.lg.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold))
                    BasicText(
                        "${modes.getValue(mode)} · °C · long-term",
                        style = Typography.sm.copy(color = colors.mutedForeground),
                    )
                }
                ToggleGroup(value = mode, onValueChange = { value -> if (value != null) mode = value }, size = ToggleSize.Sm, spacing = 0) {
                    for ((key, label) in modes) ToggleGroupItem(label, key)
                }
            }
        }
        CardContent {
            Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
                ChartContainer(chartConfig) {
                    FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
                        for (city in cities.keys) {
                            CityToggle(chartConfig[city]?.label ?: city, chartColor(city), city in visible) { pressed ->
                                visible = when {
                                    pressed -> visible + city
                                    visible.size > 1 -> visible - city
                                    else -> visible
                                }
                            }
                        }
                    }
                }
                ChartContainer(
                    chartConfig,
                    Modifier
                        .fillMaxWidth()
                        .height(288.dp),
                ) {
                    LineChart(
                        data,
                        margin = ChartMargin(top = 10.dp, right = 4.dp, bottom = 0.dp, left = 12.dp),
                        accessibilityLabel = "Monthly temperature",
                        selectedIndex = month,
                        onSelectedIndexChange = { month = it },
                    ) {
                        CartesianGrid(strokeDasharray = listOf(2f, 4f))
                        XAxis(label = { it.month }, tickMargin = 8.dp, minTickGap = 8.dp)
                        YAxis(
                            orientation = ChartAxisOrientation.Right,
                            tickMargin = 6.dp,
                            domain = -20.0..40.0,
                            ticks = listOf(-20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0),
                            tickFormatter = { "${it.toInt()}°" },
                        )
                        ReferenceLine(0.0, stroke = colors.input)
                        ChartTooltip {
                            ChartTooltipContent(
                                indicator = ChartTooltipIndicator.Line,
                                labelFormatter = { _, items ->
                                    BasicText(
                                        longMonths[items.firstOrNull()?.index ?: 0],
                                        style = Typography.xs.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold),
                                    )
                                },
                                formatter = { item ->
                                    Row(
                                        Modifier.fillMaxWidth(),
                                        horizontalArrangement = Arrangement.spacedBy(8.dp),
                                        verticalAlignment = Alignment.CenterVertically,
                                    ) {
                                        Box(
                                            Modifier
                                                .width(3.dp)
                                                .height(12.dp)
                                                .background(item.color, CircleShape),
                                        )
                                        BasicText(
                                            chartConfig[item.key]?.label ?: item.key,
                                            Modifier.weight(1f),
                                            style = Typography.xs.copy(color = colors.mutedForeground),
                                        )
                                        BasicText(
                                            "${degrees(item.value)}°",
                                            style = Typography.xs.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold, fontFeatureSettings = "tnum"),
                                        )
                                    }
                                },
                            )
                        }
                        for (city in shown) {
                            Line(
                                city,
                                value = { it.values.getValue(city) },
                                curve = ChartCurve.Monotone,
                                strokeWidth = 2.5.dp,
                                activeDot = ChartDot(5.dp, strokeColor = colors.muted, strokeWidth = 2.dp),
                                animationDuration = 650,
                                animationEasing = ChartEasing.EaseInOut,
                            )
                        }
                    }
                }
                ChartContainer(chartConfig) {
                    Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
                        for (pair in shown.chunked(2)) {
                            Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
                                for (city in pair) {
                                    val temperatures = data.map { it.values.getValue(city) }
                                    val highlighted = month?.let { temperatures.getOrNull(it) }
                                    Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
                                        Row(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically) {
                                            Box(
                                                Modifier
                                                    .size(8.dp)
                                                    .background(chartColor(city), CircleShape),
                                            )
                                            BasicText(
                                                chartConfig[city]?.label ?: city,
                                                style = Typography.sm.copy(color = colors.mutedForeground),
                                            )
                                        }
                                        BasicText(
                                            if (month == null || highlighted == null) {
                                                "${temperatures.min().roundToInt()}° / ${temperatures.max().roundToInt()}°"
                                            } else {
                                                "${highlighted.roundToInt()}° · ${longMonths[month!!]}"
                                            },
                                            style = Typography.base.copy(color = colors.foreground, fontWeight = FontWeight.SemiBold, fontFeatureSettings = "tnum"),
                                        )
                                    }
                                }
                                if (pair.size == 1) Box(Modifier.weight(1f))
                            }
                        }
                    }
                }
            }
        }
    }
}
```

**React Native**

One line per visible city across twelve months. A `ToggleGroup` switches between average, high and low temperatures, and a row of `Toggle` chips shows or hides each city, keeping at least one on. Touching the plot reports the month through `onActiveIndexChange`, and the summary under the chart switches from each city's range to its value for that month. The lines animate with `animationDuration={650}` and `animationEasing="ease-in-out"`.

Replace `CITIES` with your series and monthly values, and add a matching entry to `chartConfig` and `SWATCH` for each. The high and low values are derived in `temperature()`, so replace that with real data. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-interactive
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-interactive
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-interactive
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-interactive --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-interactive
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-interactive --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text), [Toggle](https://suiss.app/ui/docs/components/toggle), [Toggle Group](https://suiss.app/ui/docs/components/toggle-group).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Install the following dependencies:

```bash title="Terminal"
npx expo install cn
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text), [Toggle](https://suiss.app/ui/docs/components/toggle), [Toggle Group](https://suiss.app/ui/docs/components/toggle-group).

3. Copy and paste the following code into `components/charts/line-chart-interactive.tsx`:

- `uniwind/components/charts/line-chart-interactive.tsx`: shown above

4. Update the import paths to match your project setup.

**NativeWind**

1. Install the following dependencies:

```bash title="Terminal"
npx expo install cn
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text), [Toggle](https://suiss.app/ui/docs/components/toggle), [Toggle Group](https://suiss.app/ui/docs/components/toggle-group).

3. Copy and paste the following code into `components/charts/line-chart-interactive.tsx`:

```tsx title="nativewind/components/charts/line-chart-interactive.tsx"
import { cn } from "cn"
import * as React from "react"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"
import { Toggle } from "@/components/ui/toggle"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

type City = "istanbul" | "ankara" | "izmir" | "antalya" | "erzurum"

type Mode = "average" | "high" | "low"

const CITIES: Record<City, { average: number[]; spread: [number, number] }> = {
  istanbul: {
    average: [6, 6, 8, 12, 17, 22, 24, 24, 21, 16, 12, 8],
    spread: [6, 0.6],
  },
  ankara: {
    average: [0, 2, 6, 11, 16, 20, 24, 24, 19, 13, 7, 2],
    spread: [11, 1.6],
  },
  izmir: {
    average: [9, 10, 12, 16, 21, 26, 28, 28, 24, 19, 14, 10],
    spread: [9, 1],
  },
  antalya: {
    average: [10, 11, 13, 16, 21, 26, 29, 29, 25, 20, 15, 11],
    spread: [9, 0.9],
  },
  erzurum: {
    average: [-9, -8, -2, 6, 11, 15, 20, 20, 15, 8, 1, -6],
    spread: [12, 1.8],
  },
}

const CITY_KEYS = Object.keys(CITIES) as City[]

const MODES: Record<Mode, string> = {
  average: "Average",
  high: "High",
  low: "Low",
}

const MONTHS = [
  "January",
  "February",
  "March",
  "April",
  "May",
  "June",
  "July",
  "August",
  "September",
  "October",
  "November",
  "December",
]

const chartConfig = {
  istanbul: { label: "Istanbul", color: "chart-1" },
  ankara: { label: "Ankara", color: "purple-500" },
  izmir: { label: "Izmir", color: "chart-2" },
  antalya: { label: "Antalya", color: "chart-4" },
  erzurum: { label: "Erzurum", color: "chart-3" },
} satisfies ChartConfig

const SWATCH: Record<City, { dot: string; chip: string }> = {
  istanbul: { dot: "bg-blue-500", chip: "bg-blue-500/15 active:opacity-80" },
  ankara: { dot: "bg-purple-500", chip: "bg-purple-500/15 active:opacity-80" },
  izmir: { dot: "bg-teal-500", chip: "bg-teal-500/15 active:opacity-80" },
  antalya: { dot: "bg-orange-500", chip: "bg-orange-500/15 active:opacity-80" },
  erzurum: { dot: "bg-indigo-500", chip: "bg-indigo-500/15 active:opacity-80" },
}

function temperature(city: City, month: number, mode: Mode) {
  const { average, spread } = CITIES[city]
  const mean = average[month]
  if (mean === undefined) return Number.NaN
  if (mode === "average") return mean
  const season = Math.sin(((month - 0.5) / 12) * Math.PI)
  const range = spread[0] + spread[1] * 6 * season * season
  return mean + (mode === "high" ? range / 2 : -range / 2)
}

export function LineChartInteractive() {
  const [visible, setVisible] = React.useState<City[]>([
    "istanbul",
    "ankara",
    "antalya",
  ])
  const [mode, setMode] = React.useState<Mode>("average")
  const [month, setMonth] = React.useState<number | null>(null)
  const data = React.useMemo(
    () =>
      MONTHS.map((name, index) => ({
        index,
        month: name.slice(0, 3),
        ...Object.fromEntries(
          CITY_KEYS.map((city) => [
            city,
            Math.round(temperature(city, index, mode) * 10) / 10,
          ])
        ),
      })) as ({ index: number; month: string } & Record<City, number>)[],
    [mode]
  )
  const shown = CITY_KEYS.filter((city) => visible.includes(city))

  const toggle = (city: City, pressed: boolean) =>
    setVisible((current) => {
      if (pressed) return [...current, city]
      return current.length > 1
        ? current.filter((item) => item !== city)
        : current
    })

  return (
    <Card variant="filled" size="sm">
      <CardHeader className="flex-row flex-wrap items-start justify-between gap-4">
        <View className="min-w-44 grow gap-0.5">
          <Text className="text-lg font-semibold">Monthly temperature</Text>
          <Text className="text-sm text-muted-foreground">
            {MODES[mode]} · °C · long-term
          </Text>
        </View>
        <ToggleGroup
          spacing={0}
          value={[mode]}
          onValueChange={(value) => {
            if (value[0]) setMode(value[0] as Mode)
          }}
          accessibilityLabel="Temperature"
        >
          {(Object.keys(MODES) as Mode[]).map((key) => (
            <ToggleGroupItem key={key} value={key} size="sm">
              <Text>{MODES[key]}</Text>
            </ToggleGroupItem>
          ))}
        </ToggleGroup>
      </CardHeader>
      <CardContent className="gap-4">
        <View
          className="flex-row flex-wrap gap-2"
          role="group"
          accessibilityLabel="Cities"
        >
          {CITY_KEYS.map((city) => (
            <Toggle
              key={city}
              size="sm"
              pressed={visible.includes(city)}
              onPressedChange={(pressed) => toggle(city, pressed)}
              className={(state) =>
                cn(
                  "gap-1.5",
                  state.pressed
                    ? SWATCH[city].chip
                    : "bg-secondary active:opacity-80"
                )
              }
            >
              <View
                className={cn(
                  "size-2 rounded-full",
                  visible.includes(city) ? SWATCH[city].dot : "bg-border"
                )}
              />
              <Text className="text-sm font-semibold text-foreground">
                {chartConfig[city].label}
              </Text>
            </Toggle>
          ))}
        </View>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Monthly temperature"
          className="h-72 w-full"
        >
          <LineChart
            data={data}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
            onActiveIndexChange={setMonth}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} minTickGap={8} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[-20, 40]}
              ticks={[-20, -10, 0, 10, 20, 30, 40]}
              tickFormatter={(value: number) => `${value}°`}
            />
            <ReferenceLine y={0} stroke="input" />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  indicator="line"
                  labelFormatter={(_, items) =>
                    MONTHS[Number(items[0]?.payload.index ?? 0)]
                  }
                  formatter={(value, name) => (
                    <View className="w-full flex-row items-center gap-2">
                      <View
                        className={cn(
                          "h-3 w-[0.1875rem] shrink-0 rounded-full",
                          SWATCH[name as City].dot
                        )}
                      />
                      <Text className="grow text-muted-foreground">
                        {chartConfig[name as City].label}
                      </Text>
                      <Text className="font-semibold tabular-nums">
                        {String(value)}°
                      </Text>
                    </View>
                  )}
                />
              }
            />
            {shown.map((city) => (
              <Line
                animationDuration={650}
                animationEasing="ease-in-out"
                key={city}
                dataKey={city}
                type="monotone"
                strokeWidth={2.5}
                activeDot={{
                  r: 5,
                  strokeWidth: 2,
                  stroke: "muted",
                }}
              />
            ))}
          </LineChart>
        </ChartContainer>
        <View className="flex-row flex-wrap gap-3">
          {shown.map((city) => {
            const temperatures = data.map((item) => item[city])
            const highlighted = month === null ? undefined : temperatures[month]
            return (
              <View key={city} className="min-w-[8.5rem] grow basis-0 gap-0.5">
                <View className="flex-row items-center gap-1.5">
                  <View
                    className={cn(
                      "size-2 shrink-0 rounded-full",
                      SWATCH[city].dot
                    )}
                  />
                  <Text className="text-sm text-muted-foreground">
                    {chartConfig[city].label}
                  </Text>
                </View>
                <Text className="text-base font-semibold tabular-nums">
                  {month === null || highlighted === undefined
                    ? `${Math.round(Math.min(...temperatures))}° / ${Math.round(Math.max(...temperatures))}°`
                    : `${Math.round(highlighted)}° · ${MONTHS[month]}`}
                </Text>
              </View>
            )
          })}
        </View>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart), [Text](https://suiss.app/ui/docs/components/text), [Toggle](https://suiss.app/ui/docs/components/toggle), [Toggle Group](https://suiss.app/ui/docs/components/toggle-group).

2. Copy and paste the following code into `components/charts/line-chart-interactive.tsx`:

```tsx title="stylesheet/components/charts/line-chart-interactive.tsx"
import * as React from "react"
import { StyleSheet, View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import { Text } from "@/components/ui/text"
import {
  fontSize,
  palette,
  type ThemeColors,
  useTheme,
} from "@/components/ui/theme"

import { Toggle } from "@/components/ui/toggle"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

type Tone = keyof ThemeColors | keyof typeof palette

function tone(colors: ThemeColors, key: Tone) {
  return { ...colors, ...palette }[key]
}

type City = "istanbul" | "ankara" | "izmir" | "antalya" | "erzurum"

type Mode = "average" | "high" | "low"

const CITIES: Record<City, { average: number[]; spread: [number, number] }> = {
  istanbul: {
    average: [6, 6, 8, 12, 17, 22, 24, 24, 21, 16, 12, 8],
    spread: [6, 0.6],
  },
  ankara: {
    average: [0, 2, 6, 11, 16, 20, 24, 24, 19, 13, 7, 2],
    spread: [11, 1.6],
  },
  izmir: {
    average: [9, 10, 12, 16, 21, 26, 28, 28, 24, 19, 14, 10],
    spread: [9, 1],
  },
  antalya: {
    average: [10, 11, 13, 16, 21, 26, 29, 29, 25, 20, 15, 11],
    spread: [9, 0.9],
  },
  erzurum: {
    average: [-9, -8, -2, 6, 11, 15, 20, 20, 15, 8, 1, -6],
    spread: [12, 1.8],
  },
}

const CITY_KEYS = Object.keys(CITIES) as City[]

const MODES: Record<Mode, string> = {
  average: "Average",
  high: "High",
  low: "Low",
}

const MONTHS = [
  "January",
  "February",
  "March",
  "April",
  "May",
  "June",
  "July",
  "August",
  "September",
  "October",
  "November",
  "December",
]

const chartConfig = {
  istanbul: { label: "Istanbul", color: "chart-1" },
  ankara: { label: "Ankara", color: "purple-500" },
  izmir: { label: "Izmir", color: "chart-2" },
  antalya: { label: "Antalya", color: "chart-4" },
  erzurum: { label: "Erzurum", color: "chart-3" },
} satisfies ChartConfig

const SWATCH: Record<City, Tone> = {
  istanbul: "chart1",
  ankara: "purple500",
  izmir: "chart2",
  antalya: "chart4",
  erzurum: "chart3",
}

function withAlpha(color: string, alpha: number) {
  if (!color.startsWith("#") || color.length !== 7) return color
  const r = Number.parseInt(color.slice(1, 3), 16)
  const g = Number.parseInt(color.slice(3, 5), 16)
  const b = Number.parseInt(color.slice(5, 7), 16)
  return `rgba(${r}, ${g}, ${b}, ${alpha})`
}

const styles = StyleSheet.create({
  header: {
    flexDirection: "row",
    flexWrap: "wrap",
    alignItems: "flex-start",
    justifyContent: "space-between",
    gap: 16,
  },
  heading: { minWidth: 176, flexGrow: 1, gap: 2 },
  title: { ...fontSize.lg, fontWeight: "600" },
  caption: { ...fontSize.sm },
  content: { gap: 16 },
  cities: { flexDirection: "row", flexWrap: "wrap", gap: 8 },
  city: { gap: 6 },
  dot: { width: 8, height: 8, borderRadius: 9999 },
  cityLabel: { ...fontSize.sm, fontWeight: "600" },
  chart: { height: 288 },
  row: { width: "100%", flexDirection: "row", alignItems: "center", gap: 8 },
  bar: { height: 12, width: 3, flexShrink: 0, borderRadius: 9999 },
  grow: { flexGrow: 1 },
  strong: { fontWeight: "600", fontVariant: ["tabular-nums"] },
  stats: { flexDirection: "row", flexWrap: "wrap", gap: 12 },
  stat: { minWidth: 136, flexGrow: 1, flexBasis: 0, gap: 2 },
  statLabel: { flexDirection: "row", alignItems: "center", gap: 6 },
  statValue: {
    ...fontSize.base,
    fontWeight: "600",
    fontVariant: ["tabular-nums"],
  },
})

function temperature(city: City, month: number, mode: Mode) {
  const { average, spread } = CITIES[city]
  const mean = average[month]
  if (mean === undefined) return Number.NaN
  if (mode === "average") return mean
  const season = Math.sin(((month - 0.5) / 12) * Math.PI)
  const range = spread[0] + spread[1] * 6 * season * season
  return mean + (mode === "high" ? range / 2 : -range / 2)
}

export function LineChartInteractive() {
  const { colors } = useTheme()
  const [visible, setVisible] = React.useState<City[]>([
    "istanbul",
    "ankara",
    "antalya",
  ])
  const [mode, setMode] = React.useState<Mode>("average")
  const [month, setMonth] = React.useState<number | null>(null)
  const data = React.useMemo(
    () =>
      MONTHS.map((name, index) => ({
        index,
        month: name.slice(0, 3),
        ...Object.fromEntries(
          CITY_KEYS.map((city) => [
            city,
            Math.round(temperature(city, index, mode) * 10) / 10,
          ])
        ),
      })) as ({ index: number; month: string } & Record<City, number>)[],
    [mode]
  )
  const shown = CITY_KEYS.filter((city) => visible.includes(city))

  const toggle = (city: City, pressed: boolean) =>
    setVisible((current) => {
      if (pressed) return [...current, city]
      return current.length > 1
        ? current.filter((item) => item !== city)
        : current
    })

  return (
    <Card variant="filled" size="sm">
      <CardHeader style={styles.header}>
        <View style={styles.heading}>
          <Text style={styles.title}>Monthly temperature</Text>
          <Text style={[styles.caption, { color: colors.mutedForeground }]}>
            {MODES[mode]} · °C · long-term
          </Text>
        </View>
        <ToggleGroup
          spacing={0}
          value={[mode]}
          onValueChange={(value) => {
            if (value[0]) setMode(value[0] as Mode)
          }}
          accessibilityLabel="Temperature"
        >
          {(Object.keys(MODES) as Mode[]).map((key) => (
            <ToggleGroupItem key={key} value={key} size="sm">
              <Text>{MODES[key]}</Text>
            </ToggleGroupItem>
          ))}
        </ToggleGroup>
      </CardHeader>
      <CardContent style={styles.content}>
        <View style={styles.cities} role="group" accessibilityLabel="Cities">
          {CITY_KEYS.map((city) => (
            <Toggle
              key={city}
              size="sm"
              pressed={visible.includes(city)}
              onPressedChange={(pressed) => toggle(city, pressed)}
              style={(state) => [
                styles.city,
                {
                  backgroundColor: state.pressed
                    ? withAlpha(tone(colors, SWATCH[city]), 0.15)
                    : colors.secondary,
                },
              ]}
            >
              <View
                style={[
                  styles.dot,
                  {
                    backgroundColor: visible.includes(city)
                      ? tone(colors, SWATCH[city])
                      : colors.border,
                  },
                ]}
              />
              <Text style={[styles.cityLabel, { color: colors.foreground }]}>
                {chartConfig[city].label}
              </Text>
            </Toggle>
          ))}
        </View>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Monthly temperature"
          style={styles.chart}
        >
          <LineChart
            data={data}
            margin={{ top: 10, right: 4, left: 12, bottom: 0 }}
            onActiveIndexChange={setMonth}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis dataKey="month" tickMargin={8} minTickGap={8} />
            <YAxis
              orientation="right"
              tickMargin={6}
              width="auto"
              domain={[-20, 40]}
              ticks={[-20, -10, 0, 10, 20, 30, 40]}
              tickFormatter={(value: number) => `${value}°`}
            />
            <ReferenceLine y={0} stroke="input" />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  indicator="line"
                  labelFormatter={(_, items) =>
                    MONTHS[Number(items[0]?.payload.index ?? 0)]
                  }
                  formatter={(value, name) => (
                    <View style={styles.row}>
                      <View
                        style={[
                          styles.bar,
                          {
                            backgroundColor: tone(colors, SWATCH[name as City]),
                          },
                        ]}
                      />
                      <Text
                        style={[styles.grow, { color: colors.mutedForeground }]}
                      >
                        {chartConfig[name as City].label}
                      </Text>
                      <Text style={styles.strong}>{String(value)}°</Text>
                    </View>
                  )}
                />
              }
            />
            {shown.map((city) => (
              <Line
                animationDuration={650}
                animationEasing="ease-in-out"
                key={city}
                dataKey={city}
                type="monotone"
                strokeWidth={2.5}
                activeDot={{
                  r: 5,
                  strokeWidth: 2,
                  stroke: "muted",
                }}
              />
            ))}
          </LineChart>
        </ChartContainer>
        <View style={styles.stats}>
          {shown.map((city) => {
            const temperatures = data.map((item) => item[city])
            const highlighted = month === null ? undefined : temperatures[month]
            return (
              <View key={city} style={styles.stat}>
                <View style={styles.statLabel}>
                  <View
                    style={[
                      styles.dot,
                      { backgroundColor: tone(colors, SWATCH[city]) },
                    ]}
                  />
                  <Text
                    style={[styles.caption, { color: colors.mutedForeground }]}
                  >
                    {chartConfig[city].label}
                  </Text>
                </View>
                <Text style={styles.statValue}>
                  {month === null || highlighted === undefined
                    ? `${Math.round(Math.min(...temperatures))}° / ${Math.round(Math.max(...temperatures))}°`
                    : `${Math.round(highlighted)}° · ${MONTHS[month]}`}
                </Text>
              </View>
            )
          })}
        </View>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Add the Swift package to your app:

```swift title="Package.swift"
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
```

3. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

4. Copy the source and every file it uses:

- `swift/Charts/LineChartInteractive.swift`: shown above

- `swift/Components/Button.swift`: see [Button](https://suiss.app/ui/docs/components/button.md)

- `swift/Components/ButtonGroup.swift`: see [Button Group](https://suiss.app/ui/docs/components/button-group.md)

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Checkbox.swift`: see [Checkbox](https://suiss.app/ui/docs/components/checkbox.md)

- `swift/Components/Field.swift`: see [Field](https://suiss.app/ui/docs/components/field.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

- `swift/Components/Toggle.swift`: see [Toggle](https://suiss.app/ui/docs/components/toggle.md)

- `swift/Components/ToggleGroup.swift`: see [Toggle Group](https://suiss.app/ui/docs/components/toggle-group.md)

5. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
    implementation("com.adamglin:phosphor-icon-android:1.0.0")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartInteractive.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Checkbox.kt`: see [Checkbox](https://suiss.app/ui/docs/components/checkbox.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/Field.kt`: see [Field](https://suiss.app/ui/docs/components/field.md)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

- `kotlin/components/Label.kt`: see [Label](https://suiss.app/ui/docs/components/label.md)

- `kotlin/components/Separator.kt`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

- `kotlin/components/Toggle.kt`: see [Toggle](https://suiss.app/ui/docs/components/toggle.md)

- `kotlin/components/ToggleGroup.kt`: see [Toggle Group](https://suiss.app/ui/docs/components/toggle-group.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartInteractive } from "@/components/charts/line-chart-interactive"
```

```tsx
<LineChartInteractive />
```

**SwiftUI**

```swift
import SwiftUI

struct LineInteractiveExample: View {
  var body: some View {
    LineChartInteractive()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartInteractive

@Composable
fun LineInteractiveExample() {
    LineChartInteractive()
}
```



## Line Chart Labeled

A single line with a dot and a printed value at every point, and no grid.

Source: https://suiss.app/ui/docs/charts/line-chart#labeled

**React**

**Example**

```tsx title="components/charts/line-chart-labeled.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartLabeled() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Labeled</CardTitle>
        <CardDescription>Every point shows its value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 24, right: 16, left: 16, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="natural"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={{ r: 4, fill: "var(--color-desktop)", strokeWidth: 0 }}
            >
              <LabelList
                position="top"
                offset={10}
                className="fill-foreground font-semibold"
                fontSize={12}
              />
            </Line>
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A single smooth line with a dot and a printed value at every point and no grid. Choose it for short series where readers want the exact numbers without hovering.

Replace `chartData`, point each `dataKey` at your fields and set the label and color in `chartConfig`. The `position` prop on `LabelList` moves the value labels; raise the chart's top margin if they get clipped. Labels overlap on long series, so keep it to a dozen points or fewer.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-labeled
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-labeled
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-labeled.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartLabeled() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Labeled</CardTitle>
        <CardDescription>Every point shows its value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 24, right: 16, left: 16, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="natural"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={{ r: 4, fill: "var(--color-desktop)", strokeWidth: 0 }}
            >
              <LabelList
                position="top"
                offset={10}
                className="fill-foreground font-semibold"
                fontSize={12}
              />
            </Line>
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartLabeled } from "@/components/charts/line-chart-labeled"
```

```tsx
<LineChartLabeled />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-labeled.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  LabelList,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartLabeled() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Labeled</CardTitle>
        <CardDescription>Every point shows its value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Labeled"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 24, right: 16, left: 16, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="natural"
              strokeWidth={2.5}
              dot={{ r: 4 }}
            >
              <LabelList position="top" offset={10} />
            </Line>
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartLabeled.swift"
import Charts
import SwiftUI

private let chartData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
  ("May", 209, 130),
  ("June", 264, 140),
]

private let chartConfig: ChartConfig = [
  "desktop": .init("Desktop", color: EsuissColor.chart1),
]

public struct LineChartLabeled: View {
  @State private var selection: Int?

  public init() {}

  public var body: some View {
    Card(.filled, size: .sm) {
      CardHeader("Labeled", description: "Every point shows its value")
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              ForEach(chartData.indices, id: \.self) { index in
                LineMark(x: .value("Month", index), y: .value("Desktop", chartData[index].desktop))
                  .interpolationMethod(.catmullRom)
                  .lineStyle(StrokeStyle(lineWidth: 2.5, lineCap: .round, lineJoin: .round))
                  .foregroundStyle(chartConfig.color("desktop"))
                PointMark(x: .value("Month", index), y: .value("Desktop", chartData[index].desktop))
                  .symbolSize(selection == index ? 100 : 64)
                  .foregroundStyle(chartConfig.color("desktop"))
                  .annotation(position: .top, spacing: 6) {
                    Text(chartData[index].desktop, format: .number)
                      .scaledFont(TextStyle.xs, weight: .semibold)
                      .foregroundStyle(EsuissColor.foreground)
                      .opacity(progress < 1 ? 0 : 1)
                  }
              }
              .chartReveal(progress, x: 0...(chartData.count - 1))
            }
            .chartXScale(domain: 0...(chartData.count - 1), range: .plotDimension(padding: 16))
            .chartYScale(range: .plotDimension(endPadding: 24))
            .chartXAxis { ChartAxis.x(values: Array(chartData.indices)) { String(chartData[$0].month.prefix(3)) } }
            .chartYAxis(.hidden)
            .chartTooltip(
              x: Array(chartData.indices),
              labels: chartData.map(\.month),
              selection: $selection,
              accessibilityLabel: "Labeled",
              items: { [ChartTooltipItem("desktop", value: chartData[$0].desktop)] }
            ) { payload in
              ChartTooltipContent(payload, hideLabel: true)
            }
          }
        }
        .frame(height: 192)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartLabeled.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartDot
import com.esuiss.ui.components.ChartLabelList
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.LineChart
import com.esuiss.ui.theme.EsuissTheme

private class LineLabeledRow(val month: String, val desktop: Double, val mobile: Double)

private val chartData = listOf(
    LineLabeledRow("January", 186.0, 80.0),
    LineLabeledRow("February", 305.0, 200.0),
    LineLabeledRow("March", 237.0, 120.0),
    LineLabeledRow("April", 173.0, 190.0),
    LineLabeledRow("May", 209.0, 130.0),
    LineLabeledRow("June", 264.0, 140.0),
)

private val chartConfig = ChartConfig(
    "desktop" to ChartConfigItem("Desktop") { chart1 },
)

@Composable
fun LineChartLabeled(modifier: Modifier = Modifier) {
    val colors = EsuissTheme.colors
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardHeader("Labeled", description = "Every point shows its value")
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(192.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 24.dp, right = 16.dp, bottom = 0.dp, left = 16.dp),
                    accessibilityLabel = "Labeled",
                ) {
                    XAxis(label = { it.month }, tickMargin = 8.dp, interval = 0, tickFormatter = { it.take(3) })
                    ChartTooltip { ChartTooltipContent(hideLabel = true) }
                    Line(
                        "desktop",
                        value = { it.desktop },
                        curve = ChartCurve.Natural,
                        strokeWidth = 2.5.dp,
                        dot = ChartDot(4.dp),
                        labelList = ChartLabelList(offset = 10.dp, color = colors.foreground),
                    )
                }
            }
        }
    }
}
```

**React Native**

One natural curve with dots on each month and a `LabelList` above every point, so values are readable without touching the chart. There is no grid; a month axis and a tooltip remain.

Replace `chartData` with your records and change each `dataKey` to match your fields. Change `position` and `offset` on the `LabelList` to move the labels. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-labeled
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-labeled
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-labeled
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-labeled --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-labeled
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-labeled --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-labeled.tsx`:

- `uniwind/components/charts/line-chart-labeled.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-labeled.tsx`:

```tsx title="nativewind/components/charts/line-chart-labeled.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  LabelList,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartLabeled() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Labeled</CardTitle>
        <CardDescription>Every point shows its value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Labeled"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 24, right: 16, left: 16, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="natural"
              strokeWidth={2.5}
              dot={{ r: 4 }}
            >
              <LabelList position="top" offset={10} />
            </Line>
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-labeled.tsx`:

```tsx title="stylesheet/components/charts/line-chart-labeled.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  LabelList,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartLabeled() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Labeled</CardTitle>
        <CardDescription>Every point shows its value</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Labeled"
          style={{ height: 192 }}
        >
          <LineChart
            data={chartData}
            margin={{ top: 24, right: 16, left: 16, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="natural"
              strokeWidth={2.5}
              dot={{ r: 4 }}
            >
              <LabelList position="top" offset={10} />
            </Line>
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartLabeled.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartLabeled.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartLabeled } from "@/components/charts/line-chart-labeled"
```

```tsx
<LineChartLabeled />
```

**SwiftUI**

```swift
import SwiftUI

struct LineLabeledExample: View {
  var body: some View {
    LineChartLabeled()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartLabeled

@Composable
fun LineLabeledExample() {
    LineChartLabeled()
}
```



## Line Chart Linear

A single line drawn with straight segments between readings instead of a smoothed curve.

Source: https://suiss.app/ui/docs/charts/line-chart#linear

**React**

**Example**

```tsx title="components/charts/line-chart-linear.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartLinear() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Linear</CardTitle>
        <CardDescription>Straight lines between readings</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="linear"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

One series joined by straight segments instead of a smoothed curve. Prefer it to the default when smoothing would imply values between readings that were never measured.

Replace `chartData`, point each `dataKey` at your fields and set the label and color in `chartConfig`. Focus the chart and use the arrow keys to move the tooltip between months.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-linear
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-linear
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-linear.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartLinear() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Linear</CardTitle>
        <CardDescription>Straight lines between readings</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="linear"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartLinear } from "@/components/charts/line-chart-linear"
```

```tsx
<LineChartLinear />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-linear.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartLinear() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Linear</CardTitle>
        <CardDescription>Straight lines between readings</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Linear"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="linear" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartLinear.swift"
import Charts
import SwiftUI

private let chartData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
  ("May", 209, 130),
  ("June", 264, 140),
]

private let chartConfig: ChartConfig = [
  "desktop": .init("Desktop", color: EsuissColor.chart1),
]

public struct LineChartLinear: View {
  @State private var selection: Int?

  public init() {}

  public var body: some View {
    Card(.filled, size: .sm) {
      CardHeader("Linear", description: "Straight lines between readings")
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              ForEach(chartData.indices, id: \.self) { index in
                LineMark(x: .value("Month", index), y: .value("Desktop", chartData[index].desktop))
                  .interpolationMethod(.linear)
                  .lineStyle(StrokeStyle(lineWidth: 2.5, lineCap: .round, lineJoin: .round))
                  .foregroundStyle(chartConfig.color("desktop"))
              }
              .chartReveal(progress, x: 0...(chartData.count - 1))
              if let selection {
                PointMark(x: .value("Month", selection), y: .value("Desktop", chartData[selection].desktop))
                  .symbolSize(64)
                  .foregroundStyle(chartConfig.color("desktop"))
              }
            }
            .chartXScale(domain: 0...(chartData.count - 1), range: .plotDimension(padding: 12))
            .chartXAxis { ChartAxis.x(values: Array(chartData.indices)) { String(chartData[$0].month.prefix(3)) } }
            .chartYAxis { ChartAxis.grid() }
            .chartTooltip(
              x: Array(chartData.indices),
              labels: chartData.map(\.month),
              selection: $selection,
              accessibilityLabel: "Linear",
              items: { [ChartTooltipItem("desktop", value: chartData[$0].desktop)] }
            ) { payload in
              ChartTooltipContent(payload, hideLabel: true)
            }
          }
        }
        .frame(height: 192)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartLinear.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.LineChart

private class LineLinearRow(val month: String, val desktop: Double, val mobile: Double)

private val chartData = listOf(
    LineLinearRow("January", 186.0, 80.0),
    LineLinearRow("February", 305.0, 200.0),
    LineLinearRow("March", 237.0, 120.0),
    LineLinearRow("April", 173.0, 190.0),
    LineLinearRow("May", 209.0, 130.0),
    LineLinearRow("June", 264.0, 140.0),
)

private val chartConfig = ChartConfig(
    "desktop" to ChartConfigItem("Desktop") { chart1 },
)

@Composable
fun LineChartLinear(modifier: Modifier = Modifier) {
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardHeader("Linear", description = "Straight lines between readings")
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(192.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 10.dp, right = 12.dp, bottom = 0.dp, left = 12.dp),
                    accessibilityLabel = "Linear",
                ) {
                    CartesianGrid(strokeDasharray = listOf(2f, 4f))
                    XAxis(label = { it.month }, tickMargin = 8.dp, interval = 0, tickFormatter = { it.take(3) })
                    ChartTooltip { ChartTooltipContent(hideLabel = true) }
                    Line("desktop", value = { it.desktop }, curve = ChartCurve.Linear, strokeWidth = 2.5.dp)
                }
            }
        }
    }
}
```

**React Native**

One series with `type="linear"`, so each month connects to the next with a straight segment. It has a month axis, a dashed grid and a tooltip.

Replace `chartData` with your records and change each `dataKey` to match your fields. Set the label and color in `chartConfig`. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-linear
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-linear
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-linear
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-linear --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-linear
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-linear --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-linear.tsx`:

- `uniwind/components/charts/line-chart-linear.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-linear.tsx`:

```tsx title="nativewind/components/charts/line-chart-linear.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartLinear() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Linear</CardTitle>
        <CardDescription>Straight lines between readings</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Linear"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="linear" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-linear.tsx`:

```tsx title="stylesheet/components/charts/line-chart-linear.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartLinear() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Linear</CardTitle>
        <CardDescription>Straight lines between readings</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Linear"
          style={{ height: 192 }}
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="linear" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartLinear.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartLinear.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartLinear } from "@/components/charts/line-chart-linear"
```

```tsx
<LineChartLinear />
```

**SwiftUI**

```swift
import SwiftUI

struct LineLinearExample: View {
  var body: some View {
    LineChartLinear()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartLinear

@Composable
fun LineLinearExample() {
    LineChartLinear()
}
```



## Line Chart Multiple

Two lines compared on the same axes, with a legend identifying each series.

Source: https://suiss.app/ui/docs/charts/line-chart#multiple

**React**

**Example**

```tsx title="components/charts/line-chart-multiple.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function LineChartMultiple() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Multiple series</CardTitle>
        <CardDescription>With a legend</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-56 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent />} />
            <ChartLegend content={<ChartLegendContent />} />
            <Line
              dataKey="desktop"
              type="monotone"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={false}
            />
            <Line
              dataKey="mobile"
              type="monotone"
              stroke="var(--color-mobile)"
              strokeWidth={2.5}
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

Two series as smooth lines on shared axes, with a legend below. Use it to compare how two metrics move over the same period.

Replace `chartData` and rename the series keys in the data, both `Line` elements and `chartConfig`. Add a `Line` with its own config entry for each extra series; the legend and tooltip pick it up. Beyond four or five lines, consider the interactive variant that lets readers toggle series.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-multiple
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-multiple
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-multiple.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfig

export function LineChartMultiple() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Multiple series</CardTitle>
        <CardDescription>With a legend</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-56 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent />} />
            <ChartLegend content={<ChartLegendContent />} />
            <Line
              dataKey="desktop"
              type="monotone"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={false}
            />
            <Line
              dataKey="mobile"
              type="monotone"
              stroke="var(--color-mobile)"
              strokeWidth={2.5}
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartMultiple } from "@/components/charts/line-chart-multiple"
```

```tsx
<LineChartMultiple />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-multiple.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
  mobile: { label: "Mobile", color: "chart-2" },
} satisfies ChartConfig

export function LineChartMultiple() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Multiple series</CardTitle>
        <CardDescription>With a legend</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Multiple series"
          className="h-56 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent />} />
            <ChartLegend content={<ChartLegendContent />} />
            <Line dataKey="desktop" type="monotone" strokeWidth={2.5} />
            <Line dataKey="mobile" type="monotone" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartMultiple.swift"
import Charts
import SwiftUI

private let chartData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
  ("May", 209, 130),
  ("June", 264, 140),
]

private let chartConfig: ChartConfig = [
  "desktop": .init("Desktop", color: EsuissColor.chart1),
  "mobile": .init("Mobile", color: EsuissColor.chart2),
]

public struct LineChartMultiple: View {
  @State private var selection: Int?

  public init() {}

  private func value(_ key: String, _ index: Int) -> Double {
    key == "desktop" ? chartData[index].desktop : chartData[index].mobile
  }

  public var body: some View {
    Card(.filled, size: .sm) {
      CardHeader("Multiple series", description: "With a legend")
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              ForEach(chartConfig.keys, id: \.self) { key in
                ForEach(chartData.indices, id: \.self) { index in
                  LineMark(x: .value("Month", index), y: .value("Visitors", value(key, index)), series: .value("Series", key))
                    .interpolationMethod(.monotone)
                    .lineStyle(StrokeStyle(lineWidth: 2.5, lineCap: .round, lineJoin: .round))
                    .foregroundStyle(chartConfig.color(key))
                }
                .chartReveal(progress, x: 0...(chartData.count - 1))
                if let selection {
                  PointMark(x: .value("Month", selection), y: .value("Visitors", value(key, selection)))
                    .symbolSize(64)
                    .foregroundStyle(chartConfig.color(key))
                }
              }
            }
            .chartXScale(domain: 0...(chartData.count - 1), range: .plotDimension(padding: 12))
            .chartXAxis { ChartAxis.x(values: Array(chartData.indices)) { String(chartData[$0].month.prefix(3)) } }
            .chartYAxis { ChartAxis.grid() }
            .chartTooltip(
              x: Array(chartData.indices),
              labels: chartData.map(\.month),
              selection: $selection,
              accessibilityLabel: "Multiple series",
              items: { index in chartConfig.keys.map { ChartTooltipItem($0, value: value($0, index)) } }
            ) { payload in
              ChartTooltipContent(payload)
            }
          }
          ChartLegendContent()
        }
        .frame(height: 224)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartMultiple.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.LineChart

private class LineMultipleRow(val month: String, val desktop: Double, val mobile: Double)

private val chartData = listOf(
    LineMultipleRow("January", 186.0, 80.0),
    LineMultipleRow("February", 305.0, 200.0),
    LineMultipleRow("March", 237.0, 120.0),
    LineMultipleRow("April", 173.0, 190.0),
    LineMultipleRow("May", 209.0, 130.0),
    LineMultipleRow("June", 264.0, 140.0),
)

private val chartConfig = ChartConfig(
    "desktop" to ChartConfigItem("Desktop") { chart1 },
    "mobile" to ChartConfigItem("Mobile") { chart2 },
)

@Composable
fun LineChartMultiple(modifier: Modifier = Modifier) {
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardHeader("Multiple series", description = "With a legend")
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(224.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 10.dp, right = 12.dp, bottom = 0.dp, left = 12.dp),
                    accessibilityLabel = "Multiple series",
                ) {
                    CartesianGrid(strokeDasharray = listOf(2f, 4f))
                    XAxis(label = { it.month }, tickMargin = 8.dp, interval = 0, tickFormatter = { it.take(3) })
                    ChartTooltip { ChartTooltipContent() }
                    ChartLegend()
                    Line("desktop", value = { it.desktop }, curve = ChartCurve.Monotone, strokeWidth = 2.5.dp)
                    Line("mobile", value = { it.mobile }, curve = ChartCurve.Monotone, strokeWidth = 2.5.dp)
                }
            }
        }
    }
}
```

Desktop and mobile series drawn as monotone lines on the same axis. A legend below the plot names both series, and the tooltip lists each value for the touched month.

**React Native**

Replace `chartData` with your records and change each `dataKey` to match your fields. Add a `Line` and a `chartConfig` entry for each extra series; the legend picks them up. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-multiple
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-multiple
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-multiple
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-multiple --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-multiple
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-multiple --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-multiple.tsx`:

- `uniwind/components/charts/line-chart-multiple.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-multiple.tsx`:

```tsx title="nativewind/components/charts/line-chart-multiple.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
  mobile: { label: "Mobile", color: "chart-2" },
} satisfies ChartConfig

export function LineChartMultiple() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Multiple series</CardTitle>
        <CardDescription>With a legend</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Multiple series"
          className="h-56 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent />} />
            <ChartLegend content={<ChartLegendContent />} />
            <Line dataKey="desktop" type="monotone" strokeWidth={2.5} />
            <Line dataKey="mobile" type="monotone" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-multiple.tsx`:

```tsx title="stylesheet/components/charts/line-chart-multiple.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
  mobile: { label: "Mobile", color: "chart-2" },
} satisfies ChartConfig

export function LineChartMultiple() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Multiple series</CardTitle>
        <CardDescription>With a legend</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Multiple series"
          style={{ height: 224 }}
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent />} />
            <ChartLegend content={<ChartLegendContent />} />
            <Line dataKey="desktop" type="monotone" strokeWidth={2.5} />
            <Line dataKey="mobile" type="monotone" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartMultiple.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartMultiple.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartMultiple } from "@/components/charts/line-chart-multiple"
```

```tsx
<LineChartMultiple />
```

**SwiftUI**

```swift
import SwiftUI

struct LineMultipleExample: View {
  var body: some View {
    LineChartMultiple()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartMultiple

@Composable
fun LineMultipleExample() {
    LineChartMultiple()
}
```



## Line Chart Step

A single line drawn as horizontal steps, holding each value until the next reading.

Source: https://suiss.app/ui/docs/charts/line-chart#step

**React**

**Example**

```tsx title="components/charts/line-chart-step.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartStep() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Step</CardTitle>
        <CardDescription>Changes in steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="step"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

A single line drawn as flat steps that hold each value until the next reading. It fits values that change in discrete jumps, like prices, plan tiers or headcount.

Replace `chartData`, point each `dataKey` at your fields and set the label and color in `chartConfig`. Set the curve type to `stepAfter` or `stepBefore` to move where each jump happens. Focus the chart and use the arrow keys to move the tooltip between months.

### Installation

**Command**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-step
```

Works in any project with a `components.json`. See [Installation](https://suiss.app/ui/docs/installation#add-components) for the one-line registry setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-step
```

**Manual**

1. Install the following dependencies:

```bash title="Terminal"
npm install recharts
```

2. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

3. Copy and paste the following code into your project.

```tsx title="components/charts/line-chart-step.tsx"
"use client"

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

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

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function LineChartStep() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Step</CardTitle>
        <CardDescription>Changes in steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="aspect-auto h-48 w-full"
        >
          <LineChart
            accessibilityLayer
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickLine={false}
              axisLine={false}
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line
              dataKey="desktop"
              type="step"
              stroke="var(--color-desktop)"
              strokeWidth={2.5}
              dot={false}
            />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

4. Update the import paths to match your project setup.

### Usage

```tsx
import { LineChartStep } from "@/components/charts/line-chart-step"
```

```tsx
<LineChartStep />
```

**React Native, SwiftUI, Jetpack Compose**

```tsx title="uniwind/components/charts/line-chart-step.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartStep() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Step</CardTitle>
        <CardDescription>Changes in steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Step"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="step" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

```swift title="swift/Charts/LineChartStep.swift"
import Charts
import SwiftUI

private let chartData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
  ("May", 209, 130),
  ("June", 264, 140),
]

private let chartConfig: ChartConfig = [
  "desktop": .init("Desktop", color: EsuissColor.chart1),
]

public struct LineChartStep: View {
  @State private var selection: Int?

  public init() {}

  public var body: some View {
    Card(.filled, size: .sm) {
      CardHeader("Step", description: "Changes in steps")
      CardContent {
        ChartContainer(config: chartConfig) {
          ChartAnimator { progress in
            Chart {
              ForEach(chartData.indices, id: \.self) { index in
                LineMark(x: .value("Month", index), y: .value("Desktop", chartData[index].desktop))
                  .interpolationMethod(.stepCenter)
                  .lineStyle(StrokeStyle(lineWidth: 2.5, lineCap: .round, lineJoin: .round))
                  .foregroundStyle(chartConfig.color("desktop"))
              }
              .chartReveal(progress, x: 0...(chartData.count - 1))
              if let selection {
                PointMark(x: .value("Month", selection), y: .value("Desktop", chartData[selection].desktop))
                  .symbolSize(64)
                  .foregroundStyle(chartConfig.color("desktop"))
              }
            }
            .chartXScale(domain: 0...(chartData.count - 1), range: .plotDimension(padding: 12))
            .chartXAxis { ChartAxis.x(values: Array(chartData.indices)) { String(chartData[$0].month.prefix(3)) } }
            .chartYAxis { ChartAxis.grid() }
            .chartTooltip(
              x: Array(chartData.indices),
              labels: chartData.map(\.month),
              selection: $selection,
              accessibilityLabel: "Step",
              items: { [ChartTooltipItem("desktop", value: chartData[$0].desktop)] }
            ) { payload in
              ChartTooltipContent(payload, hideLabel: true)
            }
          }
        }
        .frame(height: 192)
      }
    }
  }
}
```

```kt title="kotlin/charts/LineChartStep.kt"
package com.esuiss.ui.charts

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartCurve
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.LineChart

private class LineStepRow(val month: String, val desktop: Double, val mobile: Double)

private val chartData = listOf(
    LineStepRow("January", 186.0, 80.0),
    LineStepRow("February", 305.0, 200.0),
    LineStepRow("March", 237.0, 120.0),
    LineStepRow("April", 173.0, 190.0),
    LineStepRow("May", 209.0, 130.0),
    LineStepRow("June", 264.0, 140.0),
)

private val chartConfig = ChartConfig(
    "desktop" to ChartConfigItem("Desktop") { chart1 },
)

@Composable
fun LineChartStep(modifier: Modifier = Modifier) {
    Card(modifier, variant = CardVariant.Filled, size = CardSize.Sm) {
        CardHeader("Step", description = "Changes in steps")
        CardContent {
            ChartContainer(
                chartConfig,
                Modifier
                    .fillMaxWidth()
                    .height(192.dp),
            ) {
                LineChart(
                    chartData,
                    margin = ChartMargin(top = 10.dp, right = 12.dp, bottom = 0.dp, left = 12.dp),
                    accessibilityLabel = "Step",
                ) {
                    CartesianGrid(strokeDasharray = listOf(2f, 4f))
                    XAxis(label = { it.month }, tickMargin = 8.dp, interval = 0, tickFormatter = { it.take(3) })
                    ChartTooltip { ChartTooltipContent(hideLabel = true) }
                    Line("desktop", value = { it.desktop }, curve = ChartCurve.Step, strokeWidth = 2.5.dp)
                }
            }
        }
    }
}
```

**React Native**

One series with `type="step"`, which draws flat runs and vertical jumps instead of slopes. Use it for values that change at discrete moments. It has a month axis, a dashed grid and a tooltip.

Replace `chartData` with your records and change each `dataKey` to match your fields. Set the label and color in `chartConfig`. The component takes no props.

**React Native, SwiftUI, Jetpack Compose**

### Installation

**Command**

**React Native**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-step
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-step
```

**SwiftUI**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-step
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-step --platform swift
```

**Jetpack Compose**

```bash title="Terminal"
npx shadcn@latest add @esuiss/line-chart-step
```

See [Installation](https://suiss.app/ui/docs/installation) for the `components.json` setup. Or use the [suiss/ui CLI](https://suiss.app/ui/docs/cli):

```bash title="Terminal"
npx @esuiss/ui@latest add charts line-chart-step --platform kotlin
```

**React Native**

The CLI also adds what it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

**React Native, SwiftUI, Jetpack Compose**

**Manual**

**React Native**

**Uniwind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-step.tsx`:

- `uniwind/components/charts/line-chart-step.tsx`: shown above

3. Update the import paths to match your project setup.

**NativeWind**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-step.tsx`:

```tsx title="nativewind/components/charts/line-chart-step.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartStep() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Step</CardTitle>
        <CardDescription>Changes in steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Step"
          className="h-48 w-full"
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="step" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**StyleSheet**

1. Add the pieces it builds on: [Card](https://suiss.app/ui/docs/components/card), [Chart](https://suiss.app/ui/docs/components/chart).

2. Copy and paste the following code into `components/charts/line-chart-step.tsx`:

```tsx title="stylesheet/components/charts/line-chart-step.tsx"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  XAxis,
} from "@/components/ui/chart"

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const chartConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
} satisfies ChartConfig

export function LineChartStep() {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>Step</CardTitle>
        <CardDescription>Changes in steps</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          accessibilityLabel="Step"
          style={{ height: 192 }}
        >
          <LineChart
            data={chartData}
            margin={{ top: 10, right: 12, left: 12, bottom: 0 }}
          >
            <CartesianGrid vertical={false} strokeDasharray="2 4" />
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip content={<ChartTooltipContent hideLabel />} />
            <Line dataKey="desktop" type="step" strokeWidth={2.5} />
          </LineChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}
```

3. Update the import paths to match your project setup.

**SwiftUI**

1. Target iOS 17 or later.

2. Copy the theme files every view uses:

- `swift/Theme/Theme.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Theme.swift)

- `swift/Theme/Tokens.swift`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/swiftui/Sources/EsuissUI/Theme/Tokens.swift)

3. Copy the source and every file it uses:

- `swift/Charts/LineChartStep.swift`: shown above

- `swift/Components/Card.swift`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `swift/Components/Chart.swift`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `swift/Components/Haptics.swift`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `swift/Components/Item.swift`: see [Item](https://suiss.app/ui/docs/components/item.md)

- `swift/Components/Separator.swift`: see [Separator](https://suiss.app/ui/docs/components/separator.md)

4. Add the files to your app target.

**Jetpack Compose**

1. Apply the Compose compiler plugin, enable Compose, set `compileSdk` to 37 or higher and `minSdk` to 24 or higher, and add the dependencies:

```kotlin title="build.gradle.kts"
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
```

2. Copy the theme files every view uses:

- `kotlin/theme/Theme.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Theme.kt)

- `kotlin/theme/Tokens.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/theme/Tokens.kt)

3. Copy the source and every file it uses:

- `kotlin/charts/LineChartStep.kt`: shown above

- `kotlin/components/Card.kt`: see [Card](https://suiss.app/ui/docs/components/card.md)

- `kotlin/components/Chart.kt`: see [Chart](https://suiss.app/ui/docs/components/chart.md)

- `kotlin/components/Content.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/Content.kt)

- `kotlin/components/FormSupport.kt`: [source](https://github.com/e-suiss/ui/blob/main/packages/mobile/kotlin/ui/src/main/kotlin/com/esuiss/ui/components/FormSupport.kt)

- `kotlin/components/Haptics.kt`: see [Haptics](https://suiss.app/ui/docs/components/haptics.md)

- `kotlin/components/Icon.kt`: see [Icon](https://suiss.app/ui/docs/components/icon.md)

4. Update the `com.esuiss.ui` package names to match your project.

**React Native, SwiftUI, Jetpack Compose**

### Usage

**React Native**

```tsx
import { LineChartStep } from "@/components/charts/line-chart-step"
```

```tsx
<LineChartStep />
```

**SwiftUI**

```swift
import SwiftUI

struct LineStepExample: View {
  var body: some View {
    LineChartStep()
  }
}
```

**Jetpack Compose**

```kotlin
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartStep

@Composable
fun LineStepExample() {
    LineChartStep()
}
```

