2.2.2 • Published 4 months ago

tailwindcss-plugin-icons v2.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

tailwindcss-plugin-icons

npm socket_security example license

Tailwind CSS implementation of @unocss/preset-icons.

npm install tailwindcss-plugin-icons
pnpm add tailwindcss-plugin-icons
yarn add tailwindcss-plugin-icons

How to Use

  1. Search the available icon sets at Icônes or Iconify and choose the icons your project needs.
  2. Install any required icon set with npm install @iconify-json/[the-icon-set-name].
  3. Configure the plugin in your tailwind.config file, for example, heroicons:

    import type { Config } from 'tailwindcss'
    import { Icons, type Options } from 'tailwindcss-plugin-icons'
    
    const options: Options = ({ theme }) => ({
      heroicons: {
        icons: {
          'plus-circle': {
            cursor: 'pointer',
            color: theme('colors.emerald.600'),
            '&:hover': {
              color: theme('colors.emerald.800'),
            },
          },
          'trash?bg': {},
        },
        includeAll: true,
        scale: iconName => (iconName.endsWith('-20-solid') ? 1.25 : 1.5),
        location: 'https://esm.sh/@iconify-json/heroicons@1.1.9/icons.json',
      },
    })
    
    export default {
      plugins: [Icons(options)],
    } as Config

    The plugin's options are a function. It gets forwarded 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. Finally, you can use includeAll: true to have every icon in the icon set added as a Tailwind source.

  4. Write icons with Tailwind CSS classes directly in your markup:

    <div class="i-heroicons-plus-circle"></div>
    <div class="bg-heroicons-trash-black"></div>

Comprehensive Example

2.2.2

4 months ago

2.2.1

4 months ago

2.2.0

7 months ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.3

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.8

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago