tailwindcss-plugin-icons
![LICENSE](https://badgen.net/github/license/micromatch/micromatch?color=green)
Tailwind CSS port of @unocss/preset-icons.
npm install tailwindcss-plugin-icons
pnpm add tailwindcss-plugin-icons
yarn add tailwindcss-plugin-icons
How to use
- Search the available icon sets at Icônes or Iconify and choose the icons your project needs
- Install the icon sets with
npm install @iconify-json/[the-collection-you-want]
. For example heroicons npm install @iconify-json/heroicons-outline @iconify-json/heroicons-solid
- Configure the plugin in your
tailwind.config.js
:
const { Icons } = require('tailwindcss-plugin-icons')
module.exports = {
[...]
plugins: [
Icons({
heroiconsSolid: {
icons: ['trash', 'trash?bg']
},
heroiconsOutline: {
icons: ['lock-open', 'lock-closed'],
location: 'my-icon-alias/icons.json'
},
custom: {
icons: ['loading'],
location:
'https://gist.githubusercontent.com/JensDll/4e59cf6005f585581975941a94bc1d88/raw/0e70bdac81224add27d8f0576ab15406709e5938/icons.json'
},
customAlt: {
icons: ['loading'],
location: './src/icons.json'
}
})
]
}
After the icon's name, you can pass ?mask
or ?bg
to force a specific render method. Only use ?mask
on colored and ?bg
on colorless icons. Otherwise, there is no difference from the default.
- Write icons with Tailwind CSS classes directly in your markup:
<div class="i-heroicons-solid-trash h-5 w-5"></div>