npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

iconfontail

v2.0.0

Published

iconfontail 可以用来集成 iconfont.cn 的图标到 Tailwind CSS 中,并借助 Tree Shaking 优化图标体积。

Readme

iconfontail

iconfontail 是一个将 iconfont.cn 图标集成到 Tailwind CSS v4 的插件,支持 Tree Shaking 自动优化图标体积。

特性

  • 简单集成:轻松将 iconfont 图标库与 Tailwind CSS 项目结合。
  • 多种模式:支持 SVG 和字体图标两种渲染模式。
  • 高效优化:未使用的图标类会在构建时自动移除,减少最终产物体积。
  • 灵活定制:支持自定义图标大小、颜色等样式。

安装

依赖要求:需要 Tailwind CSS v4

| npm | pnpm | bun | | :---------------------: | :----------------------: | :---------------------: | | npm install iconfontail | pnpm install iconfontail | bun install iconfontail |

快速开始

1. 下载 iconfont 资源

iconfont.cn 项目页面下载至本地,解压后将 iconfont.jsiconfont.json 以及相应的字体文件放入项目中。

2. 配置 Tailwind CSS v4

在 Tailwind CSS 入口文件中引入插件:

@import 'tailwindcss';
@plugin 'iconfontail' {
  /* 路径相对项目根目录 */
  iconfontjs: iconfont.js;
  iconfontjson: iconfont.json;
}

@font-face {
  /* font-family 应该与 iconfont.json 中相同 */
  font-family: 'iconfont';
  src:
    url('/iconfont.woff2?t=1778462439025') format('woff2'),
    url('/iconfont.woff?t=1778462439025') format('woff'),
    url('/iconfont.ttf?t=1778462439025') format('truetype');
}

3. 在 HTML 中使用

规则:

  • 图标前缀由 $.css_prefix_text 定义
  • 图标名称由 $.glyphs[*].font_class 定义
<!-- color 模式:显示原始 SVG 定义的颜色 -->
<i class="icon-home color"></i>

<!-- font 模式:使用 Unicode 渲染 -->
<i class="icon-home font"></i>

[!IMPORTANT]
使用字体模式时,需确保页面已加载 iconfont 的字体文件

常见问题

如何修改图标大小?

使用任意可以修改 font-size 的方法,例如:

<i class="icon-home color text-3xl"></i>

如何修改图标颜色?

  • color 模式:如果原始 SVG 使用 currentColor 作为填充色,可以通过修改 color 属性:
<i class="icon-home color text-blue-500"></i>
  • font 模式:直接修改 color 属性:
<i class="icon-home font text-red-500"></i>

工作原理

iconfontail 通过以下步骤实现图标集成和优化:

  1. 解析资源文件

    • 读取 iconfont.json 文件,解析 Unicode 映射和字体元信息。
    • 读取 iconfont.js 文件,提取 <symbol> 标签解析 SVG 图标。
    • 通过 iconfont.json 中的 glyphs 去索引 js 中 SVG 图标。
  2. 生成工具类

    • 为每个图标生成两类工具类:
      • .iconName.color:将 SVG 图标内联为 mask-imagebackground-image,支持 currentColor 填充。
      • .iconName.font::before:通过伪元素 ::before 渲染 Unicode 字符。
  3. Tree Shaking 优化

    • 通过 Tailwind CSS 的工具类注册机制,未使用的图标类会在构建时被自动移除,减少最终产物体积。

Inspire and Thanks

Icons in Pure CSS - antfu

License

MIT