{"_id":"@deot/style-unocss","_rev":"3-c465cf0b6bfdbede42d564d31dc6375e","name":"@deot/style-unocss","dist-tags":{"latest":"1.3.0"},"versions":{"1.2.0":{"name":"@deot/style-unocss","version":"1.2.0","keywords":["unocss","unocss-preset"],"author":{"name":"deot"},"license":"MIT","_id":"@deot/style-unocss@1.2.0","maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"homepage":"https://github.com/deot/style#readme","bugs":{"url":"https://github.com/deot/style/issues"},"dist":{"shasum":"152090b6b9c7cc87cea9c4d6adca4aa82fc5139d","tarball":"https://registry.npmjs.org/@deot/style-unocss/-/style-unocss-1.2.0.tgz","fileCount":5,"integrity":"sha512-IG5Vim/hnA7SuH+Lk8DDDWf8nl8JtLwITPwpDFuk/dIfydXvTw3vY+H9nlaASwXlErzqtSqQP8phNFlXTsMfZQ==","signatures":[{"sig":"MEQCIBpYWHCcv6GnlyRA/szLThkWuIuVSX5jbMC+d2t7t5t8AiAYmAVbUqmq+pe8lI2jdwWjM7mQrBi+PhB3y1DdZYFA7w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":47014},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"e3049e3ba0d44658fe477ba3f60c9b8f5e1590e2","_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"repository":{"url":"git+https://github.com/deot/style.git","type":"git","directory":"packages/unocss"},"_npmVersion":"11.17.0","description":"UnoCSS preset for @deot/style utilities","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"unocss":"^66.9.1"},"_npmOperationalInternal":{"tmp":"tmp/style-unocss_1.2.0_1788423284763_0.4663964567059231","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@deot/style-unocss","version":"1.2.1","keywords":["unocss","unocss-preset"],"author":{"name":"deot"},"license":"MIT","_id":"@deot/style-unocss@1.2.1","maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"homepage":"https://github.com/deot/style#readme","bugs":{"url":"https://github.com/deot/style/issues"},"dist":{"shasum":"e6d32bb2029eaa67c7f19e1b8ce3de8095399293","tarball":"https://registry.npmjs.org/@deot/style-unocss/-/style-unocss-1.2.1.tgz","fileCount":5,"integrity":"sha512-wvExQkmSrxT6OP/Xu9Wsfn+6mhQ07AIsmn+DVE/v8RHD8qsjvEfGf+U+uxkBBLbofXnrtAn/S9vkxYwSi0iggg==","signatures":[{"sig":"MEQCIHCsIthEIPp3e+u4cxZ8rXVEOBntDMDxTy4BLYq5sjkWAiAB/Y7/F66q8GXCa07nZMrZ+2dcL036CQcjG62uJHVAlg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49190},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"8bdb1b65687923ade4da0c339f54f863081a6ddb","_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"repository":{"url":"git+https://github.com/deot/style.git","type":"git","directory":"packages/unocss"},"_npmVersion":"11.17.0","description":"UnoCSS preset for @deot/style utilities","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"unocss":"^66.9.1"},"_npmOperationalInternal":{"tmp":"tmp/style-unocss_1.2.1_1788426795190_0.6215753624478584","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@deot/style-unocss","version":"1.3.0","description":"UnoCSS preset for @deot/style utilities","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"keywords":["unocss","unocss-preset"],"sideEffects":false,"author":{"name":"deot"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/deot/style.git","directory":"packages/unocss"},"bugs":{"url":"https://github.com/deot/style/issues"},"publishConfig":{"access":"public"},"dependencies":{"@unocss/extractor-arbitrary-variants":"^66.9.1","@unocss/preset-mini":"^66.9.1"},"peerDependencies":{"unocss":"^66.9.1"},"gitHead":"b799363cd62157d52b33c9167b57ce77cd7054a0","_id":"@deot/style-unocss@1.3.0","homepage":"https://github.com/deot/style#readme","_nodeVersion":"24.20.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-yvkhzv6LmVy6PvUojvJhyMwJoyAoRr8/SQwHIEHNTRmqvzypG2veEiCUSlK4wKJPvt+yDobAjopfGJ/hh4th5Q==","shasum":"5378f717e2d19505d8ddaec0ca2edf7d189aef98","tarball":"https://registry.npmjs.org/@deot/style-unocss/-/style-unocss-1.3.0.tgz","fileCount":5,"unpackedSize":96164,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIG3zzPnbqYM57RI6A56Xxg3Puyj67cz1OpHGB2sL1cFEAiAxfaKFfToNaNIqQ+II7Fii7BU2Hc77Gpw+ts53xfZOCQ=="}]},"_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"directories":{},"maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/style-unocss_1.3.0_1788699671762_0.635598215837123"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-03T08:14:44.495Z","modified":"2026-09-06T13:01:12.080Z","1.2.0":"2026-09-03T08:14:44.902Z","1.2.1":"2026-09-03T09:13:15.305Z","1.3.0":"2026-09-06T13:01:11.903Z"},"bugs":{"url":"https://github.com/deot/style/issues"},"author":{"name":"deot"},"license":"MIT","homepage":"https://github.com/deot/style#readme","keywords":["unocss","unocss-preset"],"repository":{"type":"git","url":"git+https://github.com/deot/style.git","directory":"packages/unocss"},"description":"UnoCSS preset for @deot/style utilities","maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"readme":"# @deot/style-unocss\n\n`@deot/style-unocss` 为 UnoCSS 项目提供 `@deot/style` 工具类。Preset 按源码中的 token 生成 CSS，不需要再引入 `@deot/style/dist/index.css`；默认不包含 Mini rules，但会通过官方公开入口复用 Mini variants、breakpoints 和任意 Variant 提取器。\n\n> 下一主版本不再内置 `presetMini()` 的 rules 与 preflight。原先使用 Mini-only token 的项目请阅读[与 UnoCSS Mini 组合](https://github.com/deot/style/blob/main/docs/unocss/mini.md)。\n\n> 下一主版本同时移除本 preset 中的全部 deprecated 规则。旧类临时兼容需显式安装 `@deot/style` 并加载 `@deot/style/dist/index.deprecated.css`；该 CSS 仅覆盖 Sass 已生成的普通旧类，不恢复旧 variants 或任意动态范围。映射与配置见 [Deprecated 迁移](https://github.com/deot/style/blob/main/docs/style/deprecated.md)。\n\n## 安装与配置\n\n```bash\npnpm add -D unocss @deot/style-unocss\n```\n\n```ts\n// uno.config.ts\nimport { defineConfig } from 'unocss';\nimport { presetStyle } from '@deot/style-unocss';\n\nexport default defineConfig({\n\tpresets: [presetStyle()]\n});\n```\n\nVite 项目仍需注册 UnoCSS 插件并引入 `virtual:uno.css`，完整步骤见[接入与迁移](https://github.com/deot/style/blob/main/docs/start/integration.md)。`presetStyle` 负责本仓库 rules、preflights、Mini variants 和 Variant Group transformer，不改变项目的构建入口。\n\n## 能力与阅读路径\n\n本 preset 提供当前自有工具类和动态属性扩展。完整 Token、有限枚举、任意值支持与输出声明集中在 [UnoCSS 工具类参考](https://github.com/deot/style/blob/main/docs/unocss/DOCUMENT.md)，README 只维护配置与运行方式。\n\n## Variants 与 Variant Group\n\n本 preset 通过 UnoCSS 官方公开入口复用 Mini variants、breakpoints 和任意 Variant 提取器，因此 `hover:`、`focus:`、`dark:`、`md:` 等响应式、group/peer、aria/data、任意 container、layer 与 `[&>*]:` 等写法可以直接作用于本仓库 rules。除 breakpoints 外，不注入 Mini 的 colors、spacing、containers 等 theme 内容。\n\nMini rules 与 Mini preflight 不再内置。`g-gap-*`、`g-flex-1`、`g-grid-cols-*`、transition 和 transform 等 Mini 工具类需要由项目显式组合 `presetMini()`。这不影响本仓库已有的 `g-flex-cc` 等组合类。完整配置、来源划分和冲突结果见[与 UnoCSS Mini 组合](https://github.com/deot/style/blob/main/docs/unocss/mini.md)。\n\n本 preset 仍内置 Variant Group transformer：\n\n```html\n<button class=\"hover:(g-c-white g-bg-black)\">Button</button>\n```\n\n只启用 `:` 分组，以免 CSS Variable 简写中的 `-(` 被转换；因此不支持 `g-(m-4 pd-8)`。\n\n## 配置参数\n\n`presetStyle(options?: PresetStyleOptions)` 返回 UnoCSS Preset，并导出 `PresetStyleOptions` 类型。\n\n| 参数 | 类型 | 默认值 | 控制范围 |\n| --- | --- | --- | --- |\n| `prefix` | `string` | `'g-'` | 自有规则与 group/peer 标记类前缀，原样使用 |\n| `unit` | `string` | `'px'` | 动态数字尺寸与固定尺寸的单位 |\n| `scale` | `number` | `1` | 只缩放固定语义尺寸与主题尺寸；必须为有限数字 |\n| `reset` | `boolean` | `true` | html/body/全局通配符 reset |\n| `variants` | `boolean` | `true` | 官方 variants、breakpoints 与任意 Variant 提取器 |\n| `dark` | `'class' \\| 'media' \\| { light?: string \\| string[]; dark?: string \\| string[] }` | `'class'` | 深浅色策略；自定义选择器也支持数组 |\n| `attributifyPseudo` | `boolean` | `false` | 使用属性形式的 group 等标记；不等于启用整个 Attributify preset |\n| `arbitraryVariants` | `boolean` | `true` | 任意 Variant 与其专用提取器 |\n\n### `prefix`\n\n默认值为 `'g-'`，语义与 UnoCSS `prefix` 一致，传入值原样作用于本仓库规则和 Mini tagged variants 的标记类：\n\n```ts\npresetStyle({ prefix: 'x-' });\n// x-flex、x-fs-14、x-g-4\n```\n\n传入空字符串可生成无前缀类。\n\n### `unit`\n\n默认值为 `'px'`。数值 token 直接拼接配置单位：\n\n```ts\npresetStyle({ unit: 'rem' });\n// g-fs-14 -> font-size: 14rem\n// g-pd-8  -> padding: 8rem\n// g-w-4   -> width: 4rem\n```\n\n### `scale`\n\n默认值为 `1`。动态 token 已经表达最终值，因此不应用 `scale`：\n\n```ts\npresetStyle({ unit: 'rem', scale: 2 });\n// g-fs-14 -> font-size: 14rem\n// g-w-4   -> width: 4rem\n```\n\n`scale` 只应用于 `g-dot`、`g-divider`、滚动条、默认圆角、阴影、高清边框和主题变量等固定语义尺寸。这与 Sass `$scale` 会同时缩放类名后缀和属性值的行为不同。\n\n### `reset`\n\n默认值为 `true`，输出与 Sass 默认入口一致的 `html`、`body` 和全局 `*` reset：\n\n```ts\npresetStyle({ reset: false });\n```\n\n关闭后仍保留本仓库主题变量和按需生成的 reset 工具。独立使用时不会输出 Mini preflight；显式组合 Mini 后，其 preflight 由 `presetMini()` 自身控制。\n\n### `variants`\n\n默认值为 `true`，启用 Mini 官方 variants、breakpoints 与任意 Variant 提取器。显式组合 `presetMini()` 时设置为 `false`，由外部 Mini 统一提供这些能力：\n\n```ts\npresetStyle({ variants: false });\n```\n\n`dark` 默认使用 `class`，也支持 `media` 和自定义 selectors；`attributifyPseudo` 默认是 `false`，`arbitraryVariants` 默认是 `true`。这些选项与 `prefix`、`unit`、`scale`、`reset` 一样，也可以通过 `UNOCSS_OPTIONS` 提供。\n\n## `UNOCSS_OPTIONS`\n\n参数也可以由运行 UnoCSS 的 Node 进程通过 JSON 环境变量提供：\n\n```bash\nUNOCSS_OPTIONS='{\"prefix\":\"g-\",\"unit\":\"rem\",\"scale\":2,\"reset\":true}' npm run dev\n```\n\n显式传给 `presetStyle()` 的参数优先。Preset 在加载 `uno.config.ts` 时读取 `process.env`；不使用主要面向应用源码的 `import.meta.env`。\n\n配置优先级按字段为：显式参数 > `UNOCSS_OPTIONS` > 默认值。环境变量必须是 JSON 对象字符串；JSON 解析失败会直接报错。配置在创建 preset 时读取，不跟随浏览器运行时状态变化。多入口开发流程见[接入与迁移](https://github.com/deot/style/blob/main/docs/start/integration.md)。\n\n## 动态类名与 safelist\n\nUnoCSS 只能提取源码中静态出现的完整 token。以下运行时拼接不会自动生成：\n\n```vue\n<div :class=\"`g-fs-${size}`\" />\n```\n\n应改为静态映射，或加入 safelist：\n\n```ts\nexport default defineConfig({\n\tpresets: [presetStyle()],\n\tsafelist: [12, 14, 16].map(size => `g-fs-${size}`)\n});\n```\n\n## 与 Sass/CSS 的边界\n\n- 按使用情况生成工具类时使用 `@deot/style-unocss`，不要同时引入完整的 `@deot/style` CSS。\n- 需要 Sass 函数、mixin、主题 map 或 rem/rpx 静态产物时继续使用 `@deot/style`。\n- 业务项目私有的 `g-*` 类不属于本 preset 的公共规则。\n\n## 相关文档\n\n- [选择与安装](https://github.com/deot/style/blob/main/docs/start/installation.md)\n- [接入与迁移](https://github.com/deot/style/blob/main/docs/start/integration.md)\n- [与 UnoCSS Mini 组合](https://github.com/deot/style/blob/main/docs/unocss/mini.md)\n- [工具类参考](https://github.com/deot/style/blob/main/docs/unocss/DOCUMENT.md)\n","readmeFilename":"README.md"}