Charts.css
Charts.css is an open-source, pure CSS framework designed for creating data visualizations without requiring JavaScript. It transforms semantic HTML table structures into various chart types like bar, column, line, and pie charts using only CSS classes and variables. The current stable version is 1.2.0, released on July 21, 2025. The project demonstrates an active, albeit irregular, release cadence with multiple updates in recent years. Its key differentiators include its zero-dependency nature, minimal file size (60kb minified, 6kb gzipped), and high customizability through standard CSS, making it suitable for projects prioritizing performance and simplicity by leveraging existing browser rendering capabilities.
Common errors
-
Chart bars/columns are flat or incorrectly sized despite data values being correct.
cause The `--size` CSS variable on the `<td>` element is either missing, malformed, or has an incorrect `calc()` value.fixEnsure each `<td>` element contains a `style="--size: calc( YOUR_VALUE / MAX_VALUE );"` attribute, where `YOUR_VALUE` is the data point and `MAX_VALUE` represents the 100% scale for your chart. -
Axes, grid lines, or labels are not visible on the chart.
cause The necessary axis-display classes (e.g., `show-primary-axis`, `show-4-secondary-axes`) are missing from the main `<table>` element.fixVerify that your `<table>` element includes the appropriate `charts-css` classes to enable the desired axes and grid lines as per the Charts.css documentation.
Warnings
- gotcha Charts.css relies heavily on CSS variables (custom properties) and `calc()` for dynamic sizing and styling. This means older browsers, particularly Internet Explorer 11, will not render charts correctly without polyfills or fallback styles.
- gotcha Specificity conflicts are common with pure CSS frameworks. If Charts.css styles are not applying as expected, it's likely due to higher specificity rules from other stylesheets or inline styles overriding them.
- gotcha The data visualization relies entirely on correctly formatted HTML and CSS classes/variables. Any malformed HTML structure (e.g., `<td>` outside of `<tbody>` or missing `scope='row'` on `<th>`) or incorrect class names can lead to charts not rendering or behaving unexpectedly.
Install
-
npm install charts.css -
yarn add charts.css -
pnpm add charts.css
Imports
- Charts.css Stylesheet (CDN)
<link href="https://cdn.jsdelivr.net/npm/charts.css/dist/charts.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/charts.css/dist/charts.min.css">
- Charts.css Stylesheet (NPM/Local)
@import 'charts.css';
@import 'charts.css/dist/charts.min.css';
- Charts.css Stylesheet (Local HTML)
<link rel="stylesheet" href="charts.css/dist/charts.min.css">
<link rel="stylesheet" href="./node_modules/charts.css/dist/charts.min.css">
Quickstart
<table class="charts-css column show-primary-axis show-4-secondary-axes data-spacing-4 reverse-data">
<caption> Front End Developer Salary </caption>
<thead>
<tr>
<th scope="col"> Year </th>
<th scope="col"> Income </th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"> 2016 </th>
<td style="--size: calc( 40 / 100 );"> $ 40K </td>
</tr>
<tr>
<th scope="row"> 2017 </th>
<td style="--size: calc( 60 / 100 );"> $ 60K </td>
</tr>
<tr>
<th scope="row"> 2018 </th>
<td style="--size: calc( 75 / 100 );"> $ 75K </td>
</tr>
<tr>
<th scope="row"> 2019 </th>
<td style="--size: calc( 90 / 100 );"> $ 90K </td>
</tr>
<tr>
<th scope="row"> 2020 </th>
<td style="--size: calc( 100 / 100 );"> $ 100K <br> 👑 </td>
</tr>
</tbody>
</table>