Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/ilsyaa/tw-accent-colors

Dynamic accent color TailwindCSS
https://github.com/ilsyaa/tw-accent-colors

accent-colors plugin plugins tailwindcss tailwindcss-plugin theme

Last synced: 5 days ago
JSON representation

Dynamic accent color TailwindCSS

Awesome Lists containing this project

README

        

# tailwindcss-accent

A Tailwind CSS plugin that provides `accent` color utilities using CSS custom properties based on the Tailwind CSS default color palette.

##### Example : https://ilsyaa.github.io/tw-accent-colors

## Installation

Install the plugin from npm:

```bash
npm i -D tw-accent
```

Then add the plugin to your tailwind.config.js file:

```js
module.exports = {
plugins: [
require('tw-accent')({
colors: ['violet', 'sky', 'red'],
root: 'red',
cssVarsPrefix: 'tw', // result: --tw-accent-500
attr: 'lazy-accent', // result: ...
}),
],
};
```

## Options

| Option | Description |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| colors `REQUIRED` | Include specific colors. View the available colors section. |
| root | Set color from colors option as `:root` accent color. |
| cssVarsPrefix | Set prefix for css variables name. default to 'tw-ta' (e.g: --tw-ta-accent-200) |
| attr | Set attribute name. default to 'lazy-accent' (e.g: `...`) |

> The cssVarsPrefix option can help prevent naming conflicts and make it easier for you to use accent CSS variables in your styles.

## Basic Usage

Add the lazy-accent attribute to your root/html element (or simply set the root plugin option).

```html

```

Now, instead of writing text-red-500, with this plugin you can write text-accent-500.

The accent color will follow the value of the nearest parent element's lazy-accent attribute, or the element itself.

Let the code speak:

```html

this text has a blue (:root) accent color.



this text has a violet accent color.



this text has a violet


and sky

accent color!



```

## License

MIT