Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aryan02420/postcss-themewind

A PostCSS plugin to make theming with TailwindCSS easy and fun
https://github.com/aryan02420/postcss-themewind

plugin postcss tailwindcss

Last synced: about 1 month ago
JSON representation

A PostCSS plugin to make theming with TailwindCSS easy and fun

Awesome Lists containing this project

README

        

# PostCSS Themewind

[PostCSS] plugin to make theming with [TailwindCSS] simpler.

[postcss]: https://github.com/postcss/postcss
[tailwindcss]: https://github.com/tailwindlabs/tailwindcss

```css
/* Input */
.foo {
--brand-primary: useColor(theme('colors.red.500'));
--brand-secondary: useColor(#ffee33);
}

/* Output */
.foo {
--brand-primary: 239, 68, 68;
--brand-secondary: 255, 238, 51;
}
```

## Usage

**Step 1:** Install plugin:

```sh
npm i -D postcss-themewind
```

**Step 2:** Add the plugin to `postcss.config.js`:

```diff
module.exports = {
plugins: {
tailwindcss: {},
+ 'postcss-themewind': {},
autoprefixer: {},
},
}

/* OR */

module.exports = {
plugins: [
require('tailwindcss'),
+ require('postcss-themewind'),
require('autoprefixer'),
],
}
```

**Step 3:** Modify `tailwind.config.js`:

```diff
+const { useColor } = require('postcss-themewind/utils')

module.exports = {
...
theme: {
extend: {
colors: {
brand: {
+ primary: useColor('--brand-primary'),
+ secondary: useColor('--brand-secondary'),
}
},
},
},
}
```

### Demo

[aryan02420/postcss-themewind-demo](https://github.com/aryan02420/postcss-themewind-demo/)


postcss-themewind demo