unocss-nuxt-ui 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,191 @@
1
+ # unocss-nuxt-ui
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![License][license-src]][license-href]
6
+ [![Nuxt][nuxt-src]][nuxt-href]
7
+
8
+ Use UnoCSS in place of the Tailwind CSS dependency expected by `@nuxt/ui`.
9
+
10
+ This module is built for compatibility first. It does not only swap presets. It also handles Nuxt UI runtime CSS, keyframes, generated theme files, and `app.config.ts`-driven theme overrides so that `@nuxt/ui` keeps behaving as expected.
11
+
12
+ This project is inspired by [lehuuphuc/unocss-preset-nuxt-ui](https://github.com/lehuuphuc/unocss-preset-nuxt-ui) and brought together through vibe coding.
13
+
14
+ - [✨ Release Notes](./CHANGELOG.md)
15
+
16
+ ## What It Does
17
+
18
+ - Registers `@unocss/nuxt` with `wind3: false`, `wind4: false`, and `nuxtLayers: false` defaults
19
+ - Ensures the UnoCSS config includes:
20
+ - `presetNuxtUI()`
21
+ - `presetWind4(...)`
22
+ - `presetNuxtUIExtra()`
23
+ - `transformerDirectives()`
24
+ - `transformerVariantGroup({ separators: [':'] })`
25
+ - Removes the Tailwind Vite plugin that `@nuxt/ui` would otherwise inject
26
+ - Rewrites Tailwind-style `@apply ...-(--token)` syntax into UnoCSS-compatible `var(...)` utilities
27
+ - Injects the compatibility CSS and `@nuxt/ui` runtime keyframes needed by the UI package
28
+ - Injects runtime color variables derived from `app.config.ts`
29
+ - Scans generated `.nuxt/ui/*.ts` theme files and source `app.config.*` files from all Nuxt layers
30
+
31
+ ## Requirements
32
+
33
+ - `nuxt >= 3.10.0`
34
+ - `@nuxt/ui >= 4.0.0`
35
+ - `unocss >= 0.66.0`
36
+ - `@unocss/nuxt >= 0.66.0`
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ npx nuxt module add unocss-nuxt-ui
42
+ ```
43
+
44
+ Or install manually:
45
+
46
+ ```bash
47
+ pnpm add unocss-nuxt-ui
48
+ ```
49
+
50
+ Then enable the module:
51
+
52
+ ```ts
53
+ // nuxt.config.ts
54
+ export default defineNuxtConfig({
55
+ modules: ['unocss-nuxt-ui'],
56
+ })
57
+ ```
58
+
59
+ If you want to keep `@nuxt/ui`'s original `tailwindcss/colors` import instead of aliasing it to the UnoCSS-compatible shim:
60
+
61
+ ```ts
62
+ export default defineNuxtConfig({
63
+ 'modules': ['unocss-nuxt-ui'],
64
+ 'unocss-nuxt-ui': {
65
+ tailwindColorsAlias: false,
66
+ },
67
+ })
68
+ ```
69
+
70
+ `@nuxt/ui` and `@unocss/nuxt` are declared as module dependencies, so you do not need to list them manually unless you want to be explicit.
71
+
72
+ ## Recommended Nuxt UI Config
73
+
74
+ Enable Nuxt UI component detection:
75
+
76
+ ```ts
77
+ // nuxt.config.ts
78
+ export default defineNuxtConfig({
79
+ modules: ['unocss-nuxt-ui'],
80
+ ui: {
81
+ experimental: {
82
+ componentDetection: true,
83
+ },
84
+ },
85
+ })
86
+ ```
87
+
88
+ When `ui.experimental.componentDetection` is enabled:
89
+
90
+ - `dev`: the module keeps scanning all generated Nuxt UI theme files to avoid missed styles during HMR
91
+ - `build`: the module narrows UnoCSS scanning to the generated theme files for the detected components
92
+
93
+ You do not need to add custom `.ts` scan globs in `uno.config.ts` for Nuxt UI theme files.
94
+
95
+ ## Working With `uno.config.ts`
96
+
97
+ If your app already has a `uno.config.ts`, keep it. Import the generated module config from `./.nuxt/uno.config.mjs` and merge your local config on top of it.
98
+
99
+ This is the recommended setup for the UnoCSS VS Code extension as well, because the extension can load your project-level `uno.config.ts` directly and still see the generated Nuxt UI config.
100
+
101
+ Example:
102
+
103
+ ```ts
104
+ // uno.config.ts
105
+ import { defineConfig, mergeConfigs } from 'unocss'
106
+ import uiUnoConfig from './.nuxt/uno.config.mjs'
107
+
108
+ export default mergeConfigs([
109
+ uiUnoConfig,
110
+ defineConfig({
111
+ shortcuts: {
112
+ 'btn-soft': 'px-3 py-2 rounded-md',
113
+ },
114
+ }),
115
+ ])
116
+ ```
117
+
118
+ If you use UnoCSS layer config merging with `unocss.nuxtLayers`, the generated Uno config from this module will also merge layer-level Uno config files.
119
+
120
+ ## `app.config.ts` Support
121
+
122
+ Nuxt UI stores a large part of its theme outside Vue SFCs, and user overrides are merged through `app.config.ts`. This module scans:
123
+
124
+ - generated `.nuxt/ui/*.ts` files
125
+ - generated `.nuxt/app.config.*`
126
+ - source `app.config.*` files from all Nuxt layers
127
+
128
+ That is what allows utilities referenced in theme overrides such as:
129
+
130
+ ```ts
131
+ // app.config.ts
132
+ export default defineAppConfig({
133
+ ui: {
134
+ button: {
135
+ slots: {
136
+ base: 'tracking-[0.3em]',
137
+ },
138
+ },
139
+ },
140
+ })
141
+ ```
142
+
143
+ to be emitted correctly by UnoCSS.
144
+
145
+ ## Compatibility Notes
146
+
147
+ - The module currently exposes no module options. Compatibility behavior is enabled by default.
148
+ - Build-time narrowing is precise for generated Nuxt UI theme files.
149
+ - `app.config.ts` is still scanned at file level. If you keep overrides for unused components in `app.config.ts`, some extra CSS can still be emitted during production builds. That is a tradeoff of Nuxt UI's theme merge model.
150
+
151
+ ## Exported Presets
152
+
153
+ The package also exports presets for non-module usage:
154
+
155
+ ```ts
156
+ import { defineConfig, presetWind4 } from 'unocss'
157
+ import { presetNuxtUI, presetNuxtUIExtra } from 'unocss-nuxt-ui/preset'
158
+
159
+ export default defineConfig({
160
+ presets: [
161
+ presetNuxtUI(),
162
+ presetWind4(),
163
+ presetNuxtUIExtra(),
164
+ ],
165
+ })
166
+ ```
167
+
168
+ For Nuxt applications, prefer the module unless you have a specific reason to wire everything manually.
169
+
170
+ ## Local Development
171
+
172
+ ```bash
173
+ pnpm install
174
+ pnpm run dev:prepare
175
+ pnpm run dev
176
+ pnpm run dev:build
177
+ pnpm run test
178
+ pnpm run test:types
179
+ pnpm run lint
180
+ ```
181
+
182
+ <!-- Badges -->
183
+
184
+ [npm-version-src]: https://img.shields.io/npm/v/unocss-nuxt-ui/latest.svg?style=flat&colorA=020420&colorB=00DC82
185
+ [npm-version-href]: https://npmjs.com/package/unocss-nuxt-ui
186
+ [npm-downloads-src]: https://img.shields.io/npm/dm/unocss-nuxt-ui.svg?style=flat&colorA=020420&colorB=00DC82
187
+ [npm-downloads-href]: https://npm.chart.dev/unocss-nuxt-ui
188
+ [license-src]: https://img.shields.io/npm/l/unocss-nuxt-ui.svg?style=flat&colorA=020420&colorB=00DC82
189
+ [license-href]: https://npmjs.com/package/unocss-nuxt-ui
190
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt
191
+ [nuxt-href]: https://nuxt.com