You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integrating Feliz.Shadcn into your SAFE Stack application is straightforward. The following example demonstrates how to integrate Shadcn copmonents within an existing SAFE app.
4
+
5
+
We will be using the [Feliz.Shadcn](https://github.com/reaptor/feliz.shadcn) wrapper written by [reaptor](https://github.com/reaptor)
6
+
7
+
1. Setup Tailwind
8
+
9
+
> Note: When you use the SAFE template you will already have Tailwind installed by default. You can skip this step.
10
+
11
+
Check out the following recipe here to install tailwind: [Add Tailwind](https://safe-stack.github.io/docs/recipes/ui/add-tailwind/)
12
+
13
+
1. Move `package.json` & `package-lock.json` to /src/Client
14
+
15
+
1. Configure import alias in tsconfig:
16
+
17
+
Create a file named tsconfig.json in `/src/Client` and add the following:
18
+
19
+
{
20
+
"files": [],
21
+
"compilerOptions": {
22
+
"baseUrl": ".",
23
+
"paths": {
24
+
"@/*": [
25
+
"./*"
26
+
]
27
+
}
28
+
}
29
+
}
30
+
31
+
1. Install shadcn/ui
32
+
33
+
> Note: ensure your node version is > 20.5.0
34
+
35
+
```
36
+
npx shadcn@latest init
37
+
```
38
+
39
+
You will be asked a few questions to configure components.json
40
+
41
+
1. Add Feliz.Shadcn
42
+
43
+
Inside the `/src/Client` directory run:
44
+
45
+
```
46
+
dotnet add package Feliz.Shadcn
47
+
```
48
+
49
+
1. Start adding any shadcn component
50
+
51
+
Specify first which components you want to use.
52
+
You can find the list of available components [here](https://reaptor.github.io/Feliz.Shadcn/):
53
+
54
+
```
55
+
npx shadcn@latest add button
56
+
```
57
+
58
+
1. Then use it in Feliz:
59
+
60
+
```fsharp
61
+
open Feliz.Shadcn
62
+
63
+
64
+
let view =
65
+
Shadcn.button [
66
+
prop.text "Button" ]
67
+
68
+
```
69
+
70
+
Congratulations, now you can use shadcn components!
71
+
Documentation can be found at [https://reaptor.github.io/Feliz.Shadcn/](https://reaptor.github.io/Feliz.Shadcn/)
0 commit comments