@@ -16,22 +16,14 @@ Components are styled using Tailwind CSS. You need to install Tailwind CSS in yo
1616Add the following dependencies to your project:
1717
1818``` 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
2820```
2921
3022### Configure path aliases
3123
32- I use the ` @ ` alias. This is how I configure it in tsconfig.json:
24+ Configure the path aliases in your ` tsconfig.json ` file.
3325
34- ``` json {3-6} title="tsconfig.json"
26+ ``` json {3-6} title="tsconfig.json" showLineNumbers
3527{
3628 "compilerOptions" : {
3729 "baseUrl" : " ." ,
@@ -44,27 +36,16 @@ I use the `@` alias. This is how I configure it in tsconfig.json:
4436
4537The ` @ ` alias is a preference. You can use other aliases if you want.
4638
47- ** If you use a different alias such as ~ , you'll need to update import statements when adding components.**
48-
4939### Configure tailwind.config.js
5040
5141Here's what my ` tailwind.config.js ` file looks like:
5242
5343``` js title="tailwind.config.js"
54- const { fontFamily } = require (" tailwindcss/defaultTheme" )
55-
5644/** @type {import('tailwindcss').Config} */
5745module .exports = {
5846 darkMode: [" class" ],
5947 content: [" app/**/*.{ts,tsx}" , " components/**/*.{ts,tsx}" ],
6048 theme: {
61- container: {
62- center: true ,
63- padding: " 2rem" ,
64- screens: {
65- " 2xl" : " 1400px" ,
66- },
67- },
6849 extend: {
6950 colors: {
7051 border: " hsl(var(--border))" ,
@@ -106,23 +87,6 @@ module.exports = {
10687 md: ` calc(var(--radius) - 2px)` ,
10788 sm: " calc(var(--radius) - 4px)" ,
10889 },
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- },
12690 },
12791 },
12892 plugins: [require (" tailwindcss-animate" )],
@@ -142,67 +106,46 @@ Add the following to your styles/globals.css file. You can learn more about usin
142106 :root {
143107 --background : 0 0% 100% ;
144108 --foreground : 222.2 47.4% 11.2% ;
145-
146109 --muted : 210 40% 96.1% ;
147110 --muted-foreground : 215.4 16.3% 46.9% ;
148-
149111 --popover : 0 0% 100% ;
150112 --popover-foreground : 222.2 47.4% 11.2% ;
151-
152113 --border : 214.3 31.8% 91.4% ;
153114 --input : 214.3 31.8% 91.4% ;
154-
155115 --card : 0 0% 100% ;
156116 --card-foreground : 222.2 47.4% 11.2% ;
157-
158117 --primary : 222.2 47.4% 11.2% ;
159118 --primary-foreground : 210 40% 98% ;
160-
161119 --secondary : 210 40% 96.1% ;
162120 --secondary-foreground : 222.2 47.4% 11.2% ;
163-
164121 --accent : 210 40% 96.1% ;
165122 --accent-foreground : 222.2 47.4% 11.2% ;
166-
167123 --destructive : 0 100% 50% ;
168124 --destructive-foreground : 210 40% 98% ;
169-
170125 --ring : 215 20.2% 65.1% ;
171-
172126 --radius : 0.5rem ;
173127 }
174128
175129 .dark {
176130 --background : 224 71% 4% ;
177131 --foreground : 213 31% 91% ;
178-
179132 --muted : 223 47% 11% ;
180133 --muted-foreground : 215.4 16.3% 56.9% ;
181-
182134 --accent : 216 34% 17% ;
183135 --accent-foreground : 210 40% 98% ;
184-
185136 --popover : 224 71% 4% ;
186137 --popover-foreground : 215 20.2% 65.1% ;
187-
188138 --border : 216 34% 17% ;
189139 --input : 216 34% 17% ;
190-
191140 --card : 224 71% 4% ;
192141 --card-foreground : 213 31% 91% ;
193-
194142 --primary : 210 40% 98% ;
195143 --primary-foreground : 222.2 47.4% 1.2% ;
196-
197144 --secondary : 222.2 47.4% 11.2% ;
198145 --secondary-foreground : 210 40% 98% ;
199-
200146 --destructive : 0 63% 31% ;
201147 --destructive-foreground : 210 40% 98% ;
202-
203148 --ring : 216 34% 17% ;
204-
205- --radius : 0.5rem ;
206149 }
207150}
208151
@@ -211,17 +154,14 @@ Add the following to your styles/globals.css file. You can learn more about usin
211154 @apply border-border ;
212155 }
213156 body {
214- @apply bg-background text-foreground ;
215- font-feature-settings : " rlig" 1 , " calt" 1 ;
157+ @apply font-sans antialiased bg-background text-foreground ;
216158 }
217159}
218160```
219161
220162### Add a cn helper
221163
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
225165import { clsx , type ClassValue } from " clsx"
226166import { twMerge } from " tailwind-merge"
227167
@@ -230,6 +170,34 @@ export function cn(...inputs: ClassValue[]) {
230170}
231171```
232172
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+
233201### That's it
234202
235203You can now start adding components to your project.
0 commit comments