# Styling with custom properties (Chartist example)

> The same area chart twice, the second one restyled only by setting --ct-* custom properties.

`src/main.ts`:

```ts
import 'chartist/styles.css';
import './style.css';
import { lineChart } from 'chartist';

// The same chart twice: the second container sets --ct-* properties.
for (const cell of document.querySelectorAll('.cell')) {
  lineChart(
    cell,
    {
      labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
      series: [
        [12, 9, 7, 8, 5],
        [2, 1, 3.5, 7, 3]
      ]
    },
    { showArea: true, fullWidth: true, chartPadding: { right: 30 } }
  );
}
```

`index.html`:

```html
<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script type="module" src="/src/main.ts"></script>
  </head>
  <body>
    <div id="chart">
      <div class="cell"></div>
      <div class="cell themed"></div>
    </div>
  </body>
</html>
```

`src/style.css`:

```css
#chart {
  display: flex;
  gap: 24px;
}

.cell {
  width: 480px;
  height: 300px;
}

/* Custom properties restyle one chart; the other keeps the defaults. */
.themed {
  --ct-series-a: #0544d3;
  --ct-series-b: #59922b;
  --ct-line-width: 2px;
  --ct-point-size: 6px;
  --ct-grid-dasharray: none;
  --ct-grid-color: rgb(5 68 211 / 0.15);
  --ct-label-color: #0544d3;
  --ct-area-opacity: 0.25;
}

/* Narrower windows: the two charts share the width, and fit the height. */
@media (max-width: 1000px) {
  #chart {
    gap: 12px;
  }

  .cell {
    box-sizing: border-box;
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: min(300px, calc(100vh - 40px));
  }
}
```
