Skip to content

Commit 23629e7

Browse files
committed
Create ui-components.mdc
1 parent 1de66f5 commit 23629e7

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
description: Describes where the ui components built on top with Shadcn UI exist, how they are customized, and Wasp specific rules concerning how new ShadCN UI components should be installed
3+
alwaysApply: false
4+
---
5+
Only ShadCN UI version 2.3.0 should be used with Wasp at the moment. Due to dependency conflicts Wasp cannot be used with Tailwindcss v4, which the newer version of Shadcn depends on.
6+
7+
Shadcn has already been setup with this project template, so there is no need to install it. All the ShadCN specific components exist in [src/components/ui](../../src/components/ui/)
8+
9+
## Adding a new ShadCN component
10+
### 1. Add a new component
11+
12+
```bash
13+
npx [email protected] add button
14+
```
15+
16+
### 2. Adjust the `utils` import in `button.tsx` (for each component you add)
17+
18+
There will be a brand new `button.tsx` file in `src/components/ui`. We need to fix some import issues:
19+
```diff
20+
import * as React from "react"
21+
import { Slot } from "@radix-ui/react-slot"
22+
import { cva, type VariantProps } from "class-variance-authority"
23+
24+
-import { cn } from "s/lib/utils"
25+
+import { cn } from "../../lib/utils"
26+
```
27+
28+
### 3. Use the `Button` component
29+
Now you are ready to use the `Button` component. That's it!
30+
```jsx
31+
import './Main.css'
32+
33+
import { Button } from './components/ui/button'
34+
35+
export const MainPage = () => {
36+
return (
37+
<div className="container">
38+
<Button>This works</Button>
39+
</div>
40+
)
41+
}

0 commit comments

Comments
 (0)