-
Notifications
You must be signed in to change notification settings - Fork 71
Add shadcn recipe to docs #372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3383730
Add shadcn recipe to docs
arpxspace de8879a
add new recipe to mkdocs.yml
arpxspace 4473001
add forgotten codeblock
arpxspace e22dceb
update list layout
arpxspace 673be9f
remove step 2 which is no longer needed
arpxspace f5e4729
changes
arpxspace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# How do I add shadcn to a SAFE project? | ||
|
||
> Note: The SAFE.Template has recently been updated to move `package.json` and `package-lock.json`. If you are using a version of the template prior to this change, you will need to move those files into the `src/Client` directory. For reference, here is the [PR](https://github.com/SAFE-Stack/SAFE-template/pull/658) detailing this change. | ||
|
||
Integrating Feliz.Shadcn into your SAFE Stack application is straightforward. The following example demonstrates how to integrate Shadcn copmonents within an existing SAFE app. | ||
|
||
We will be using the [Feliz.Shadcn](https://github.com/reaptor/feliz.shadcn) wrapper written by [reaptor](https://github.com/reaptor) | ||
|
||
#### 1. Setup Tailwind | ||
> Note: When you use the SAFE template you will already have Tailwind installed by default. You can skip this step. | ||
|
||
Check out the following recipe here to install Tailwind: [Add Tailwind](https://safe-stack.github.io/docs/recipes/ui/add-tailwind/) | ||
|
||
#### 2. Configure import alias in tsconfig: | ||
|
||
Create a file named `tsconfig.json` in `/src/Client` and add the following: | ||
|
||
```json | ||
{ | ||
"files": [], | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": [ | ||
"./*" | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
#### 3. Update the `vite.config.mts` within `/src/Client` | ||
|
||
Add the `resolve` property below under the `defineConfig` | ||
|
||
``` | ||
export default defineConfig({ | ||
... | ||
resolve: { | ||
alias: { | ||
"@": path.resolve(__dirname), | ||
}, | ||
}, | ||
... | ||
}); | ||
``` | ||
|
||
#### 4. Install shadcn/ui | ||
|
||
> Note: ensure your node version is > 20.5.0 | ||
|
||
Inside the `/src/Client` directory run: | ||
``` | ||
npx shadcn@latest init | ||
``` | ||
|
||
You will be asked a few questions to configure components.json | ||
|
||
#### 5. Add Feliz.Shadcn | ||
|
||
Inside the `/src/Client` directory run: | ||
``` | ||
dotnet add package Feliz.Shadcn | ||
``` | ||
|
||
#### 6. Start adding any shadcn component | ||
|
||
Specify first which components you want to use. | ||
You can find the list of available components [here](https://reaptor.github.io/Feliz.Shadcn/): | ||
|
||
Inside the `/src/Client` directory run: | ||
``` | ||
npx shadcn@latest add button | ||
``` | ||
|
||
#### 7. Use it in Feliz: | ||
|
||
```fsharp | ||
open Feliz.Shadcn | ||
|
||
|
||
let view = | ||
Shadcn.button [ | ||
prop.text "Button" ] | ||
|
||
``` | ||
|
||
Congratulations, now you can use shadcn components! | ||
Further documentation can be found at [https://reaptor.github.io/Feliz.Shadcn/](https://reaptor.github.io/Feliz.Shadcn/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.