├── package.json ├── index.js └── readme.md /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tailwind-caret-color", 3 | "version": "1.0.4", 4 | "description": "Tailwind plugin to create caret color classes", 5 | "main": "index.js", 6 | "repository": "https://github.com/Naoray/tailwind-caret-color", 7 | "author": "Krishan Koenig", 8 | "license": "MIT", 9 | "private": false 10 | } 11 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = function () { 3 | return function ({ e, addUtilities, theme }) { 4 | colors = theme('colors'); 5 | 6 | const caretColors = Object.keys(colors) 7 | .reduce((acc, key) => { 8 | if (typeof colors[key] === 'string') { 9 | return { 10 | ...acc, 11 | [`.caret-${e(key)}`]: { 12 | 'caret-color': colors[key] 13 | }, 14 | }; 15 | } 16 | 17 | const variants = Object.keys(colors[key]); 18 | 19 | return { 20 | ...acc, 21 | ...variants.reduce((a, variant) => ({ 22 | ...a, 23 | [`.caret-${e(key)}-${variant}`]: { 24 | 'caret-color': colors[key][variant] 25 | }, 26 | }), {}), 27 | }; 28 | 29 | }, {}); 30 | 31 | addUtilities(caretColors); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Caret Color - TailwindCSS Plugin 2 | 3 | [![npm](https://img.shields.io/npm/v/tailwind-caret-color.svg?style=flat-square)](https://www.npmjs.com/package/tailwind-caret-color) 4 | [![npm](https://img.shields.io/npm/dt/tailwind-caret-color.svg?style=flat-square)](https://www.npmjs.com/package/tailwind-caret-color) 5 | 6 | This plugin generates classes for coloring carets using `caret-color: #;`. 7 | 8 | ## Installation 9 | 10 | Pull it in through npm or yarn: 11 | 12 | ```bash 13 | npm install tailwind-caret-color 14 | ``` 15 | 16 | ```bash 17 | yarn add tailwind-caret-color 18 | ``` 19 | 20 | ## Usage 21 | 22 | Add it to the plugins array of your Tailwind config. 23 | 24 | ```js 25 | plugins: [ 26 | // Other plugins 27 | require('tailwind-caret-color')(), 28 | ], 29 | ``` 30 | 31 | For each color in `colors` config of tailwind a `caret-{color}` class is created, analog to `bg-` and `text-` classes. 32 | 33 | ## License 34 | 35 | This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). 36 | --------------------------------------------------------------------------------