@@ -16,22 +16,14 @@ Components are styled using Tailwind CSS. You need to install Tailwind CSS in yo
16
16
Add the following dependencies to your project:
17
17
18
18
``` bash
19
- npm install tailwindcss-animate class-variance-authority clsx tailwind-merge
20
- ```
21
-
22
- ### Add icon library
23
-
24
- If you're using the ` default ` style, install ` lucide-react ` :
25
-
26
- ``` bash
27
- npm install lucide-react
19
+ npm install tailwindcss-animate class-variance-authority clsx tailwind-merge lucide-react
28
20
```
29
21
30
22
### Configure path aliases
31
23
32
- I use the ` @ ` alias. This is how I configure it in tsconfig.json:
24
+ Configure the path aliases in your ` tsconfig.json ` file.
33
25
34
- ``` json {3-6} title="tsconfig.json"
26
+ ``` json {3-6} title="tsconfig.json" showLineNumbers
35
27
{
36
28
"compilerOptions" : {
37
29
"baseUrl" : " ." ,
@@ -44,27 +36,16 @@ I use the `@` alias. This is how I configure it in tsconfig.json:
44
36
45
37
The ` @ ` alias is a preference. You can use other aliases if you want.
46
38
47
- ** If you use a different alias such as ~ , you'll need to update import statements when adding components.**
48
-
49
39
### Configure tailwind.config.js
50
40
51
41
Here's what my ` tailwind.config.js ` file looks like:
52
42
53
43
``` js title="tailwind.config.js"
54
- const { fontFamily } = require (" tailwindcss/defaultTheme" )
55
-
56
44
/** @type {import('tailwindcss').Config} */
57
45
module .exports = {
58
46
darkMode: [" class" ],
59
47
content: [" app/**/*.{ts,tsx}" , " components/**/*.{ts,tsx}" ],
60
48
theme: {
61
- container: {
62
- center: true ,
63
- padding: " 2rem" ,
64
- screens: {
65
- " 2xl" : " 1400px" ,
66
- },
67
- },
68
49
extend: {
69
50
colors: {
70
51
border: " hsl(var(--border))" ,
@@ -106,23 +87,6 @@ module.exports = {
106
87
md: ` calc(var(--radius) - 2px)` ,
107
88
sm: " calc(var(--radius) - 4px)" ,
108
89
},
109
- fontFamily: {
110
- sans: [" var(--font-sans)" , ... fontFamily .sans ],
111
- },
112
- keyframes: {
113
- " accordion-down" : {
114
- from: { height: " 0" },
115
- to: { height: " var(--radix-accordion-content-height)" },
116
- },
117
- " accordion-up" : {
118
- from: { height: " var(--radix-accordion-content-height)" },
119
- to: { height: " 0" },
120
- },
121
- },
122
- animation: {
123
- " accordion-down" : " accordion-down 0.2s ease-out" ,
124
- " accordion-up" : " accordion-up 0.2s ease-out" ,
125
- },
126
90
},
127
91
},
128
92
plugins: [require (" tailwindcss-animate" )],
@@ -142,67 +106,46 @@ Add the following to your styles/globals.css file. You can learn more about usin
142
106
:root {
143
107
--background : 0 0% 100% ;
144
108
--foreground : 222.2 47.4% 11.2% ;
145
-
146
109
--muted : 210 40% 96.1% ;
147
110
--muted-foreground : 215.4 16.3% 46.9% ;
148
-
149
111
--popover : 0 0% 100% ;
150
112
--popover-foreground : 222.2 47.4% 11.2% ;
151
-
152
113
--border : 214.3 31.8% 91.4% ;
153
114
--input : 214.3 31.8% 91.4% ;
154
-
155
115
--card : 0 0% 100% ;
156
116
--card-foreground : 222.2 47.4% 11.2% ;
157
-
158
117
--primary : 222.2 47.4% 11.2% ;
159
118
--primary-foreground : 210 40% 98% ;
160
-
161
119
--secondary : 210 40% 96.1% ;
162
120
--secondary-foreground : 222.2 47.4% 11.2% ;
163
-
164
121
--accent : 210 40% 96.1% ;
165
122
--accent-foreground : 222.2 47.4% 11.2% ;
166
-
167
123
--destructive : 0 100% 50% ;
168
124
--destructive-foreground : 210 40% 98% ;
169
-
170
125
--ring : 215 20.2% 65.1% ;
171
-
172
126
--radius : 0.5rem ;
173
127
}
174
128
175
129
.dark {
176
130
--background : 224 71% 4% ;
177
131
--foreground : 213 31% 91% ;
178
-
179
132
--muted : 223 47% 11% ;
180
133
--muted-foreground : 215.4 16.3% 56.9% ;
181
-
182
134
--accent : 216 34% 17% ;
183
135
--accent-foreground : 210 40% 98% ;
184
-
185
136
--popover : 224 71% 4% ;
186
137
--popover-foreground : 215 20.2% 65.1% ;
187
-
188
138
--border : 216 34% 17% ;
189
139
--input : 216 34% 17% ;
190
-
191
140
--card : 224 71% 4% ;
192
141
--card-foreground : 213 31% 91% ;
193
-
194
142
--primary : 210 40% 98% ;
195
143
--primary-foreground : 222.2 47.4% 1.2% ;
196
-
197
144
--secondary : 222.2 47.4% 11.2% ;
198
145
--secondary-foreground : 210 40% 98% ;
199
-
200
146
--destructive : 0 63% 31% ;
201
147
--destructive-foreground : 210 40% 98% ;
202
-
203
148
--ring : 216 34% 17% ;
204
-
205
- --radius : 0.5rem ;
206
149
}
207
150
}
208
151
@@ -211,17 +154,14 @@ Add the following to your styles/globals.css file. You can learn more about usin
211
154
@apply border-border ;
212
155
}
213
156
body {
214
- @apply bg-background text-foreground ;
215
- font-feature-settings : " rlig" 1 , " calt" 1 ;
157
+ @apply font-sans antialiased bg-background text-foreground ;
216
158
}
217
159
}
218
160
```
219
161
220
162
### Add a cn helper
221
163
222
- I use a ` cn ` helper to make it easier to conditionally add Tailwind CSS classes. Here's how I define it in ` lib/utils.ts ` :
223
-
224
- ``` ts title="lib/utils.ts"
164
+ ``` ts title="lib/utils.ts" showLineNumbers
225
165
import { clsx , type ClassValue } from " clsx"
226
166
import { twMerge } from " tailwind-merge"
227
167
@@ -230,6 +170,34 @@ export function cn(...inputs: ClassValue[]) {
230
170
}
231
171
```
232
172
173
+ ### Create a ` components.json ` file
174
+
175
+ Create a ` components.json ` file in the root of your project.
176
+
177
+ ``` json title="components.json" showLineNumbers
178
+ {
179
+ "$schema" : " https://ui.shadcn.com/schema.json" ,
180
+ "style" : " new-york" ,
181
+ "rsc" : false ,
182
+ "tsx" : true ,
183
+ "tailwind" : {
184
+ "config" : " tailwind.config.js" ,
185
+ "css" : " src/index.css" ,
186
+ "baseColor" : " zinc" ,
187
+ "cssVariables" : true ,
188
+ "prefix" : " "
189
+ },
190
+ "aliases" : {
191
+ "components" : " @/components" ,
192
+ "utils" : " @/lib/utils" ,
193
+ "ui" : " @/components/ui" ,
194
+ "lib" : " @/lib" ,
195
+ "hooks" : " @/hooks"
196
+ },
197
+ "iconLibrary" : " lucide"
198
+ }
199
+ ```
200
+
233
201
### That's it
234
202
235
203
You can now start adding components to your project.
0 commit comments