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]
. - Configure the plugin in your
tailwind.config.js
:
const { Icons } = require('tailwindcss-plugin-icons')
const options = ({ theme }) => ({
heroiconsOutline: {
icons: {
lockOpen: {},
lockClosed: {},
plusCircle: {
cursor: 'pointer',
color: theme('colors.emerald.600'),
'&:hover': {
color: theme('colors.emerald.700')
}
},
minusCircle: {
cursor: 'pointer',
color: theme('colors.red.600'),
'&:hover': {
color: theme('colors.red.700')
},
'.dark &': {
color: theme('colors.red.400')
}
},
'trash?bg': {}
},
scale: 1.5,
location: 'https://esm.sh/@iconify-json/heroicons-outline@1.1.4/icons.json'
}
})
module.exports = {
plugins: [Icons(options)]
}
Options
gets forwarded all of the Tailwind CSS plugin API and returns the selected icons with optional default style and scale. After the icon's name, you can pass ?bg
or ?mask
to force a specific render method (see also example).
- Write icons with Tailwind CSS classes directly in your markup:
<div class="i-heroicons-outline-plus-circle"></div>