Skip to content

Instantly share code, notes, and snippets.

View Pipe-Runner's full-sized avatar
Hello there...

PIPΞ RUNNΞR Pipe-Runner

Hello there...
View GitHub Profile
@Pipe-Runner
Pipe-Runner / tailwind-colors-as-css-variables.md
Created August 16, 2023 23:07 — forked from Merott/tailwind-colors-as-css-variables.md
Expose Tailwind colors as CSS custom properties (variables)

This is a simple Tailwind plugin to expose all of Tailwind's colors, including any custom ones, as custom css properties on the :root element.

There are a couple of main reasons this is helpful:

  • You can reference all of Tailwind's colors—including any custom ones you define—from handwritten CSS code.
  • You can define all of your colors within the Tailwind configuration, and access the final values programmatically, which isn't possible if you did it the other way around: referencing custom CSS variables (defined in CSS code) from your Tailwind config.

See the Tailwind Plugins for more info on plugins.