npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chartjs-plugin-tailwindcss-colors

v0.2.5

Published

Colorize your Chart.js components using TailwindCSS!

Readme

chartjs-plugin-tailwindcss-colors

yarn current chart.js peer dependency version tailwindcss peer dependency version npm type definitions npm (latest) CI contributions welcome

Colorize your Chart.js components using TailwindCSS!

This plugin integrates your existing TailwindCSS colors configuration so you can continue to use it on your Chart.js components, without the hassle.

Getting started

Installation

Package:

yarn add chartjs-plugin-tailwindcss-colors # or npm install

CDN:

<script src="https://cdn.jsdelivr.net/npm/chart.js@<version>/dist/chart.umd.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>

<!-- UMD -->
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-tailwindcss-colors@<version>/dist/plugin.umd.min.js"></script>
<script>
  Chart.register(twColorsPlugin(tailwind.config))
</script>

<!-- or as an ESM -->
<script type="module">
  import twColorsPlugin from "https://cdn.jsdelivr.net/npm/chartjs-plugin-tailwindcss-colors@<version>/+esm"
</script>

Integration

Simply include the plugin inside the plugins options in your Chart.js instance's config, provide your TailwindCSS config, and give it some color options:

import twColorsPlugin from "chartjs-plugin-tailwindcss-colors"
import twConfig from "./tailwind.config"

const config = {
  data: {
    datasets: [
      {
        data: [...],
        borderColor: "yellow-500",
        backgroundColor: "yellow-500/50", // or #eab308/50
      },
    ],
  },
  plugins: [twColorsPlugin(twConfig)],
}

// ...
const chart = new Chart(ctx, config)

And that's about it, you're good to go!

NOTE: Only tested with vanilla JS and react-chartjs-2 using chart.js@3 as of initial release. If you encounter problems with other frameworks and versions of Chart.js, please feel free to submit to the issue tracker!

Parsable Chart Options

In addition to the above, it can also parse the following color options:

  • color
  • hoverBorderColor
  • hoverBackgroundColor
  • pointBorderColor
  • pointBackgroundColor
  • pointHoverBackgroundColor
  • pointHoverBorderColor
  • fill.above
  • fill.below

Global Defaults

To set the global colors, you can register it and add defaults:

Chart.register(twColorsPlugin(tailwindConfig))

Chart.defaults.borderColor = "yellow-500"
Chart.defaults.backgroundColor = "yellow-500/50" // or #eab308/50

Now if a chart's parsable option is not configured, it will fallback to the values provided above.

NOTE: Since this plugin is still on its initial release, there might be other overlooked color options left to be parsed (also, bugs). As such, feedback is highly encouraged!

Why did I even make this?

I absolutely love how fast I can prototype things with TailwindCSS. However, keeping my Chart.js component's colors consistent with my TailwindCSS config has been pretty much a hassle, to say the least. While you can just use TailwindCSS's resolveConfig helper function, it is far more intuitive and convenient to just use TailwindCSS color classes directly rather than something like fullConfig.theme.colors.red[500]. What's more, it doesn't even handle opacity, which is something I use all the time.

That's why this plugin was made in order to seamlessly blend Chart.js's color options with my TailwindCSS workflow. Now I'm sharing this with all of you!

Contributing

For making feature requests and other related information, please refer to the contributing guidelines. This project is tested with BrowserStack.

License

chartjs-plugin-tailwindcss-colors is available under the MIT license.