create-huenei-template 0.2.3 → 0.2.4
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/dist/templates/frontend/angular-base/.cursor/skills/angular-component/SKILL.md +288 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-component/references/component-patterns.md +358 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-di/SKILL.md +387 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-di/references/di-patterns.md +519 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-directives/SKILL.md +437 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-directives/references/directive-patterns.md +570 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-forms/SKILL.md +434 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-forms/references/form-patterns.md +398 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-http/SKILL.md +366 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-http/references/http-patterns.md +448 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-routing/SKILL.md +395 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-routing/references/routing-patterns.md +472 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-signals/SKILL.md +302 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-signals/references/signal-patterns.md +404 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-ssr/SKILL.md +435 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-ssr/references/ssr-patterns.md +497 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-testing/SKILL.md +660 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-testing/references/testing-patterns.md +707 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-tooling/SKILL.md +352 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-tooling/references/tooling-patterns.md +448 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-accessibility/SKILL.md +780 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-components/SKILL.md +718 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-design-systems/SKILL.md +612 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-layouts/SKILL.md +594 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-animations/SKILL.md +432 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-animations/references/animation-patterns.md +427 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-debugging/SKILL.md +354 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-debugging/references/troubleshooting-guide.md +306 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/SKILL.md +578 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/references/react-patterns.md +353 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/SKILL.md +608 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/references/advanced-theme-patterns.md +215 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/references/custom-utilities-guide.md +281 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-mobile-first/SKILL.md +768 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-performance/SKILL.md +374 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-performance/references/bundle-optimization.md +244 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-plugins/SKILL.md +505 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-responsive-darkmode/SKILL.md +601 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-responsive-darkmode/references/advanced-responsive-patterns.md +485 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/web-design-guidelines/SKILL.md +39 -0
- package/dist/templates/frontend/angular-base/package.json +0 -1
- package/dist/templates/frontend/angular-base/pnpm-lock.yaml +8183 -0
- package/package.json +1 -1
- package/templates/frontend/angular-base/.cursor/skills/angular-component/SKILL.md +288 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-component/references/component-patterns.md +358 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-di/SKILL.md +387 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-di/references/di-patterns.md +519 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-directives/SKILL.md +437 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-directives/references/directive-patterns.md +570 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-forms/SKILL.md +434 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-forms/references/form-patterns.md +398 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-http/SKILL.md +366 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-http/references/http-patterns.md +448 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-routing/SKILL.md +395 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-routing/references/routing-patterns.md +472 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-signals/SKILL.md +302 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-signals/references/signal-patterns.md +404 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-ssr/SKILL.md +435 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-ssr/references/ssr-patterns.md +497 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-testing/SKILL.md +660 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-testing/references/testing-patterns.md +707 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-tooling/SKILL.md +352 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-tooling/references/tooling-patterns.md +448 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-accessibility/SKILL.md +780 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-components/SKILL.md +718 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-design-systems/SKILL.md +612 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-layouts/SKILL.md +594 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-animations/SKILL.md +432 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-animations/references/animation-patterns.md +427 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-debugging/SKILL.md +354 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-debugging/references/troubleshooting-guide.md +306 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/SKILL.md +578 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/references/react-patterns.md +353 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/SKILL.md +608 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/references/advanced-theme-patterns.md +215 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/references/custom-utilities-guide.md +281 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-mobile-first/SKILL.md +768 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-performance/SKILL.md +374 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-performance/references/bundle-optimization.md +244 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-plugins/SKILL.md +505 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-responsive-darkmode/SKILL.md +601 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-responsive-darkmode/references/advanced-responsive-patterns.md +485 -0
- package/templates/frontend/angular-base/.cursor/skills/web-design-guidelines/SKILL.md +39 -0
- package/templates/frontend/angular-base/package.json +0 -1
- package/templates/frontend/angular-base/pnpm-lock.yaml +8183 -0
- package/templates/frontend/angular-base/package-lock.json +0 -13321
package/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/SKILL.md
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tailwindcss-framework-integration
|
|
3
|
+
description: Tailwind CSS integration guide for React, Vue, Next.js, and other frameworks
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tailwind CSS Framework Integration
|
|
7
|
+
|
|
8
|
+
## React with Vite
|
|
9
|
+
|
|
10
|
+
### Setup
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Create React + Vite project
|
|
14
|
+
npm create vite@latest my-app -- --template react-ts
|
|
15
|
+
cd my-app
|
|
16
|
+
|
|
17
|
+
# Install Tailwind CSS
|
|
18
|
+
npm install -D tailwindcss @tailwindcss/vite
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Configuration
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
// vite.config.ts
|
|
25
|
+
import { defineConfig } from 'vite'
|
|
26
|
+
import react from '@vitejs/plugin-react'
|
|
27
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
28
|
+
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
plugins: [react(), tailwindcss()]
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```css
|
|
35
|
+
/* src/index.css */
|
|
36
|
+
@import "tailwindcss";
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
// src/main.tsx
|
|
41
|
+
import React from 'react'
|
|
42
|
+
import ReactDOM from 'react-dom/client'
|
|
43
|
+
import App from './App'
|
|
44
|
+
import './index.css'
|
|
45
|
+
|
|
46
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
47
|
+
<React.StrictMode>
|
|
48
|
+
<App />
|
|
49
|
+
</React.StrictMode>
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Component Example
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
// src/components/Button.tsx
|
|
57
|
+
interface ButtonProps {
|
|
58
|
+
variant?: 'primary' | 'secondary' | 'outline'
|
|
59
|
+
size?: 'sm' | 'md' | 'lg'
|
|
60
|
+
children: React.ReactNode
|
|
61
|
+
onClick?: () => void
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const variants = {
|
|
65
|
+
primary: 'bg-blue-600 text-white hover:bg-blue-700',
|
|
66
|
+
secondary: 'bg-gray-200 text-gray-900 hover:bg-gray-300',
|
|
67
|
+
outline: 'border-2 border-blue-600 text-blue-600 hover:bg-blue-50'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const sizes = {
|
|
71
|
+
sm: 'px-3 py-1.5 text-sm',
|
|
72
|
+
md: 'px-4 py-2 text-base',
|
|
73
|
+
lg: 'px-6 py-3 text-lg'
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function Button({
|
|
77
|
+
variant = 'primary',
|
|
78
|
+
size = 'md',
|
|
79
|
+
children,
|
|
80
|
+
onClick
|
|
81
|
+
}: ButtonProps) {
|
|
82
|
+
return (
|
|
83
|
+
<button
|
|
84
|
+
onClick={onClick}
|
|
85
|
+
className={`
|
|
86
|
+
inline-flex items-center justify-center
|
|
87
|
+
font-medium rounded-lg
|
|
88
|
+
transition-colors duration-200
|
|
89
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2
|
|
90
|
+
disabled:opacity-50 disabled:cursor-not-allowed
|
|
91
|
+
${variants[variant]}
|
|
92
|
+
${sizes[size]}
|
|
93
|
+
`}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</button>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Next.js
|
|
102
|
+
|
|
103
|
+
### Setup (App Router)
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Create Next.js project (Tailwind included by default)
|
|
107
|
+
npx create-next-app@latest my-app
|
|
108
|
+
cd my-app
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
If adding to existing project:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm install -D tailwindcss @tailwindcss/postcss
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Configuration
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
// postcss.config.mjs
|
|
121
|
+
export default {
|
|
122
|
+
plugins: {
|
|
123
|
+
'@tailwindcss/postcss': {}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```css
|
|
129
|
+
/* app/globals.css */
|
|
130
|
+
@import "tailwindcss";
|
|
131
|
+
|
|
132
|
+
@theme {
|
|
133
|
+
--color-primary: oklch(0.6 0.2 250);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
// app/layout.tsx
|
|
139
|
+
import './globals.css'
|
|
140
|
+
|
|
141
|
+
export default function RootLayout({
|
|
142
|
+
children
|
|
143
|
+
}: {
|
|
144
|
+
children: React.ReactNode
|
|
145
|
+
}) {
|
|
146
|
+
return (
|
|
147
|
+
<html lang="en">
|
|
148
|
+
<body className="bg-white dark:bg-gray-900">{children}</body>
|
|
149
|
+
</html>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Server Components
|
|
155
|
+
|
|
156
|
+
Tailwind works seamlessly with React Server Components:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
// app/page.tsx (Server Component)
|
|
160
|
+
export default function Home() {
|
|
161
|
+
return (
|
|
162
|
+
<main className="container mx-auto px-4 py-8">
|
|
163
|
+
<h1 className="text-4xl font-bold text-gray-900 dark:text-white">
|
|
164
|
+
Welcome
|
|
165
|
+
</h1>
|
|
166
|
+
<p className="mt-4 text-gray-600 dark:text-gray-300">
|
|
167
|
+
Server-rendered with Tailwind
|
|
168
|
+
</p>
|
|
169
|
+
</main>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Dark Mode with next-themes
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
npm install next-themes
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
// app/providers.tsx
|
|
182
|
+
'use client'
|
|
183
|
+
|
|
184
|
+
import { ThemeProvider } from 'next-themes'
|
|
185
|
+
|
|
186
|
+
export function Providers({ children }: { children: React.ReactNode }) {
|
|
187
|
+
return (
|
|
188
|
+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
|
189
|
+
{children}
|
|
190
|
+
</ThemeProvider>
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
// app/layout.tsx
|
|
197
|
+
import { Providers } from './providers'
|
|
198
|
+
import './globals.css'
|
|
199
|
+
|
|
200
|
+
export default function RootLayout({
|
|
201
|
+
children
|
|
202
|
+
}: {
|
|
203
|
+
children: React.ReactNode
|
|
204
|
+
}) {
|
|
205
|
+
return (
|
|
206
|
+
<html lang="en" suppressHydrationWarning>
|
|
207
|
+
<body>
|
|
208
|
+
<Providers>{children}</Providers>
|
|
209
|
+
</body>
|
|
210
|
+
</html>
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
```css
|
|
216
|
+
/* globals.css - Add dark mode variant */
|
|
217
|
+
@import "tailwindcss";
|
|
218
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Vue 3
|
|
222
|
+
|
|
223
|
+
### Setup with Vite
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm create vue@latest my-app
|
|
227
|
+
cd my-app
|
|
228
|
+
|
|
229
|
+
npm install -D tailwindcss @tailwindcss/vite
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Configuration
|
|
233
|
+
|
|
234
|
+
```javascript
|
|
235
|
+
// vite.config.ts
|
|
236
|
+
import { defineConfig } from 'vite'
|
|
237
|
+
import vue from '@vitejs/plugin-vue'
|
|
238
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
239
|
+
|
|
240
|
+
export default defineConfig({
|
|
241
|
+
plugins: [vue(), tailwindcss()]
|
|
242
|
+
})
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```css
|
|
246
|
+
/* src/assets/main.css */
|
|
247
|
+
@import "tailwindcss";
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
// src/main.ts
|
|
252
|
+
import { createApp } from 'vue'
|
|
253
|
+
import App from './App.vue'
|
|
254
|
+
import './assets/main.css'
|
|
255
|
+
|
|
256
|
+
createApp(App).mount('#app')
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Component Example
|
|
260
|
+
|
|
261
|
+
```vue
|
|
262
|
+
<!-- src/components/Button.vue -->
|
|
263
|
+
<script setup lang="ts">
|
|
264
|
+
defineProps<{
|
|
265
|
+
variant?: 'primary' | 'secondary'
|
|
266
|
+
}>()
|
|
267
|
+
</script>
|
|
268
|
+
|
|
269
|
+
<template>
|
|
270
|
+
<button
|
|
271
|
+
class="px-4 py-2 rounded-lg font-medium transition-colors"
|
|
272
|
+
:class="{
|
|
273
|
+
'bg-blue-600 text-white hover:bg-blue-700': variant === 'primary',
|
|
274
|
+
'bg-gray-200 text-gray-900 hover:bg-gray-300': variant === 'secondary'
|
|
275
|
+
}"
|
|
276
|
+
>
|
|
277
|
+
<slot />
|
|
278
|
+
</button>
|
|
279
|
+
</template>
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Scoped Styles with @reference
|
|
283
|
+
|
|
284
|
+
```vue
|
|
285
|
+
<template>
|
|
286
|
+
<h1>Hello world!</h1>
|
|
287
|
+
</template>
|
|
288
|
+
|
|
289
|
+
<style scoped>
|
|
290
|
+
/* Reference global Tailwind definitions */
|
|
291
|
+
@reference "../../assets/main.css";
|
|
292
|
+
|
|
293
|
+
h1 {
|
|
294
|
+
@apply text-2xl font-bold text-blue-600;
|
|
295
|
+
}
|
|
296
|
+
</style>
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Alternative: CSS Variables
|
|
300
|
+
|
|
301
|
+
```vue
|
|
302
|
+
<template>
|
|
303
|
+
<h1>Hello world!</h1>
|
|
304
|
+
</template>
|
|
305
|
+
|
|
306
|
+
<style scoped>
|
|
307
|
+
h1 {
|
|
308
|
+
/* Use CSS variables directly - better performance */
|
|
309
|
+
font-size: var(--text-2xl);
|
|
310
|
+
font-weight: var(--font-bold);
|
|
311
|
+
color: var(--color-blue-600);
|
|
312
|
+
}
|
|
313
|
+
</style>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Nuxt 3
|
|
317
|
+
|
|
318
|
+
### Setup
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
npx nuxi init my-app
|
|
322
|
+
cd my-app
|
|
323
|
+
|
|
324
|
+
npm install -D tailwindcss @tailwindcss/postcss
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Configuration
|
|
328
|
+
|
|
329
|
+
```javascript
|
|
330
|
+
// postcss.config.mjs
|
|
331
|
+
export default {
|
|
332
|
+
plugins: {
|
|
333
|
+
'@tailwindcss/postcss': {}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
```css
|
|
339
|
+
/* assets/css/main.css */
|
|
340
|
+
@import "tailwindcss";
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
// nuxt.config.ts
|
|
345
|
+
export default defineNuxtConfig({
|
|
346
|
+
css: ['~/assets/css/main.css']
|
|
347
|
+
})
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Svelte / SvelteKit
|
|
351
|
+
|
|
352
|
+
### Setup
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
npm create svelte@latest my-app
|
|
356
|
+
cd my-app
|
|
357
|
+
|
|
358
|
+
npm install -D tailwindcss @tailwindcss/vite
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Configuration
|
|
362
|
+
|
|
363
|
+
```javascript
|
|
364
|
+
// vite.config.js
|
|
365
|
+
import { sveltekit } from '@sveltejs/kit/vite'
|
|
366
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
367
|
+
import { defineConfig } from 'vite'
|
|
368
|
+
|
|
369
|
+
export default defineConfig({
|
|
370
|
+
plugins: [sveltekit(), tailwindcss()]
|
|
371
|
+
})
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
```css
|
|
375
|
+
/* src/app.css */
|
|
376
|
+
@import "tailwindcss";
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
```svelte
|
|
380
|
+
<!-- src/routes/+layout.svelte -->
|
|
381
|
+
<script>
|
|
382
|
+
import '../app.css'
|
|
383
|
+
</script>
|
|
384
|
+
|
|
385
|
+
<slot />
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Component Example
|
|
389
|
+
|
|
390
|
+
```svelte
|
|
391
|
+
<!-- src/lib/Button.svelte -->
|
|
392
|
+
<script lang="ts">
|
|
393
|
+
export let variant: 'primary' | 'secondary' = 'primary'
|
|
394
|
+
</script>
|
|
395
|
+
|
|
396
|
+
<button
|
|
397
|
+
class="px-4 py-2 rounded-lg font-medium transition-colors
|
|
398
|
+
{variant === 'primary' ? 'bg-blue-600 text-white hover:bg-blue-700' : ''}
|
|
399
|
+
{variant === 'secondary' ? 'bg-gray-200 text-gray-900 hover:bg-gray-300' : ''}"
|
|
400
|
+
>
|
|
401
|
+
<slot />
|
|
402
|
+
</button>
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## Astro
|
|
406
|
+
|
|
407
|
+
### Setup
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
npm create astro@latest my-app
|
|
411
|
+
cd my-app
|
|
412
|
+
|
|
413
|
+
npx astro add tailwind
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Manual Setup
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
npm install -D tailwindcss @tailwindcss/vite
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
```javascript
|
|
423
|
+
// astro.config.mjs
|
|
424
|
+
import { defineConfig } from 'astro/config'
|
|
425
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
426
|
+
|
|
427
|
+
export default defineConfig({
|
|
428
|
+
vite: {
|
|
429
|
+
plugins: [tailwindcss()]
|
|
430
|
+
}
|
|
431
|
+
})
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
```css
|
|
435
|
+
/* src/styles/global.css */
|
|
436
|
+
@import "tailwindcss";
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
```astro
|
|
440
|
+
<!-- src/layouts/Layout.astro -->
|
|
441
|
+
---
|
|
442
|
+
import '../styles/global.css'
|
|
443
|
+
---
|
|
444
|
+
<html lang="en">
|
|
445
|
+
<head>
|
|
446
|
+
<meta charset="UTF-8" />
|
|
447
|
+
<title>My Site</title>
|
|
448
|
+
</head>
|
|
449
|
+
<body class="bg-white dark:bg-gray-900">
|
|
450
|
+
<slot />
|
|
451
|
+
</body>
|
|
452
|
+
</html>
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## Remix
|
|
456
|
+
|
|
457
|
+
### Setup
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
npx create-remix@latest my-app
|
|
461
|
+
cd my-app
|
|
462
|
+
|
|
463
|
+
npm install -D tailwindcss @tailwindcss/vite
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Configuration
|
|
467
|
+
|
|
468
|
+
```javascript
|
|
469
|
+
// vite.config.ts
|
|
470
|
+
import { vitePlugin as remix } from '@remix-run/dev'
|
|
471
|
+
import { defineConfig } from 'vite'
|
|
472
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
473
|
+
|
|
474
|
+
export default defineConfig({
|
|
475
|
+
plugins: [remix(), tailwindcss()]
|
|
476
|
+
})
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
```css
|
|
480
|
+
/* app/tailwind.css */
|
|
481
|
+
@import "tailwindcss";
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
```tsx
|
|
485
|
+
// app/root.tsx
|
|
486
|
+
import stylesheet from './tailwind.css?url'
|
|
487
|
+
import { Links } from '@remix-run/react'
|
|
488
|
+
|
|
489
|
+
export const links = () => [
|
|
490
|
+
{ rel: 'stylesheet', href: stylesheet }
|
|
491
|
+
]
|
|
492
|
+
|
|
493
|
+
export default function App() {
|
|
494
|
+
return (
|
|
495
|
+
<html>
|
|
496
|
+
<head>
|
|
497
|
+
<Links />
|
|
498
|
+
</head>
|
|
499
|
+
<body className="bg-white dark:bg-gray-900">
|
|
500
|
+
<Outlet />
|
|
501
|
+
</body>
|
|
502
|
+
</html>
|
|
503
|
+
)
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
## Best Practices for All Frameworks
|
|
508
|
+
|
|
509
|
+
### 1. Use the Prettier Plugin
|
|
510
|
+
|
|
511
|
+
```bash
|
|
512
|
+
npm install -D prettier prettier-plugin-tailwindcss
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
```json
|
|
516
|
+
// .prettierrc
|
|
517
|
+
{
|
|
518
|
+
"plugins": ["prettier-plugin-tailwindcss"]
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### 2. Install VS Code Extension
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
code --install-extension bradlc.vscode-tailwindcss
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### 3. Create Reusable Components
|
|
529
|
+
|
|
530
|
+
Don't repeat long class strings—extract components:
|
|
531
|
+
|
|
532
|
+
```tsx
|
|
533
|
+
// Instead of repeating this everywhere:
|
|
534
|
+
<button className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
|
|
535
|
+
|
|
536
|
+
// Create a component:
|
|
537
|
+
<Button variant="primary">Click me</Button>
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### 4. Use clsx or tailwind-merge for Conditional Classes
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
npm install clsx tailwind-merge
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
```tsx
|
|
547
|
+
import { clsx } from 'clsx'
|
|
548
|
+
import { twMerge } from 'tailwind-merge'
|
|
549
|
+
|
|
550
|
+
function cn(...inputs: ClassValue[]) {
|
|
551
|
+
return twMerge(clsx(inputs))
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Usage
|
|
555
|
+
<div className={cn(
|
|
556
|
+
"base-class",
|
|
557
|
+
isActive && "active-class",
|
|
558
|
+
disabled && "opacity-50"
|
|
559
|
+
)} />
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### 5. Configure Path Aliases
|
|
563
|
+
|
|
564
|
+
```json
|
|
565
|
+
// tsconfig.json
|
|
566
|
+
{
|
|
567
|
+
"compilerOptions": {
|
|
568
|
+
"paths": {
|
|
569
|
+
"@/*": ["./src/*"],
|
|
570
|
+
"@/components/*": ["./src/components/*"]
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
```tsx
|
|
577
|
+
import { Button } from '@/components/Button'
|
|
578
|
+
```
|