unocss
它能做什么
这项技能说明如何使用 UnoCSS 为网站设置样式。它是一种直接在类名中编写样式的快速方法。适合熟悉 Tailwind 或想找一种灵活替代方案的开发者。
适用场景
- ✓当你在网页项目中设置 UnoCSS 或修改其配置文件时。
- ✓当你想为重复使用的类组合添加自定义样式规则或快捷方式时。
- ✓当你想使用主题颜色、断点,或悬停和深色模式变体的时候。
技能链接
https://github.com/antfu/skills/blob/main/skills/unocss/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在我的项目中设置 UnoCSS,并为我的标准按钮样式添加一个快捷方式。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体先检查项目的 UnoCSS 配置,然后使用项目已有的预设、快捷方式和主题,以原子类的形式编写样式。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
UnoCSS is an instant atomic CSS engine designed to be flexible and extensible. The core is un-opinionated - all CSS utilities are provided via presets. It's a superset of Tailwind CSS, so you can reuse your Tailwind knowledge for basic syntax usage.
Important: Before writing UnoCSS code, agents should check for uno.config.* or unocss.config.* files in the project root to understand what presets, rules, and shortcuts are available. If the project setup is unclear, avoid using attributify mode and other advanced features - stick to basic class usage.
The skill is based on UnoCSS v66.10.5, generated at 2026-09-25.
Core
| Topic | Description | Reference |
|---|---|---|
| Configuration | Config file setup and all configuration options | core-config |
| Rules | Static and dynamic rules for generating CSS utilities | core-rules |
| Shortcuts | Combine multiple rules into single shorthands | core-shortcuts |
| Theme | Theming system for colors, breakpoints, and design tokens | core-theme |
| Variants | Apply variations like hover:, dark:, responsive to rules | core-variants |
| Extracting | How UnoCSS extracts utilities from source code | core-extracting |
| Safelist & Blocklist | Force include or exclude specific utilities | core-safelist |
| Layers & Preflights | CSS layer ordering and raw CSS injection | core-layers |
| Processors | Transform generated CSS layers (incl. Lightning CSS) | core-processors |
Presets
Main Presets
| Topic | Description | Reference |
|---|---|---|
| Preset Wind3 | Tailwind CSS v3 / Windi CSS compatible preset (most common) | preset-wind3 |
| Preset Wind4 | Tailwind CSS v4 compatible preset with modern CSS features | preset-wind4 |
| Preset Mini | Minimal preset with essential utilities for custom builds | preset-mini |
Feature Presets
| Topic | Description | Reference |
|---|---|---|
| Preset Icons | Pure CSS icons using Iconify with any icon set | preset-icons |
| Preset Attributify | Group utilities in HTML attributes instead of class | preset-attributify |
| Preset Typography | Prose classes for typographic defaults | preset-typography |
| Preset Web Fonts | Easy Google Fonts and other web fonts integration | preset-web-fonts |
| Preset Tagify | Use utilities as HTML tag names | preset-tagify |
| Preset Rem to Px | Convert rem units to px for utilities | preset-rem-to-px |
Transformers
| Topic | Description | Reference |
|---|---|---|
| Variant Group | Shorthand for grouping utilities with common prefixes | transformer-variant-group |
| Directives | CSS directives: @apply, @screen, theme(), icon() | transformer-directives |
| Compile Class | Compile multiple classes into one hashed class | transformer-compile-class |
| Attributify JSX | Support valueless attributify in JSX/TSX | transformer-attributify-jsx |
Integrations
| Topic | Description | Reference |
|---|---|---|
| Vite Integration | Setting up UnoCSS with Vite and framework-specific tips | integrations-vite |
| Nuxt Integration | UnoCSS module for Nuxt applications | integrations-nuxt |
常见问题
UnoCSS 和 Tailwind 一样吗?
不一样,但很相似。描述中说它是 Tailwind 的超集,因此大多数 Tailwind 类名都可以使用。
如果我的项目设置不清楚怎么办?
智能体会坚持使用简单的类名,在设置清楚之前避免使用高级功能。
什么是预设?
预设是一组现成的样式原子类,例如用于 Tailwind 风格类名的 Wind,以及用于图标类名的 Icons。
详情
作者的原始描述
UnoCSS instant atomic CSS engine, superset of Tailwind CSS. Use when configuring UnoCSS, writing utility rules, shortcuts, or working with presets like Wind, Icons, Attributify.
repo: antfu/skills
热度
- GitHub 星标
- 6.0k
- 排名
- #14444
- 许可证
- MIT
- 更新时间
- 2026/10/30
评论
- …