Feliz.Shadcn
0.9.4
dotnet add package Feliz.Shadcn --version 0.9.4
NuGet\Install-Package Feliz.Shadcn -Version 0.9.4
<PackageReference Include="Feliz.Shadcn" Version="0.9.4" />
<PackageVersion Include="Feliz.Shadcn" Version="0.9.4" />
<PackageReference Include="Feliz.Shadcn" />
paket add Feliz.Shadcn --version 0.9.4
#r "nuget: Feliz.Shadcn, 0.9.4"
#addin nuget:?package=Feliz.Shadcn&version=0.9.4
#tool nuget:?package=Feliz.Shadcn&version=0.9.4
Feliz.Shadcn
Fable/Feliz types for the Shadcn UI component library.
Read the documentation for more information.
TL;DR
1. Install shadcn/ui
https://ui.shadcn.com/docs/installation/vite
2. Install Feliz.Shadcn
dotnet add package Feliz.Shadcn
3. Start using the components
open Feliz.Shadcn
Shadcn.button [
prop.text "Click me"
prop.onClick (fun _ -> Browser.Dom.window.alert "Hello, shadcn/ui!")
]
Setting Up Feliz.Shadcn with Elmish Land
Integrating Feliz.Shadcn into your Elmish Land application is straightforward. The following example demonstrates how to set up a basic Elmish Land app that incorporates Shadcn components.
1. Create a new Elmish Land project
mkdir FelizShadcnIntro
cd FelizShadcnIntro
dotnet new tool-manifest
dotnet tool install elmish-land
dotnet elmish-land init
2. Install Tailwind CSS
npm install tailwindcss @tailwindcss/vite
3. Configure Vite
Add the @tailwindcss/vite plugin and shadcn's component alias to your Vite configuration vite.config.js
:
import { defineConfig } from 'vite'
// highlight-start
import path from "path"
import tailwindcss from '@tailwindcss/vite'
// highlight-end
export default defineConfig({
// highlight-start
plugins: [
tailwindcss(),
],
// highlight-end
build: {
outDir: "dist"
},
// highlight-start
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
// highlight-end
})
4. Import Tailwind CSS
Create a file named styles.css
in the root folder of your project and add an @import
for Tailwind CSS.
@import "tailwindcss";
5. Add your CSS file to index.html
Add a link to your styles.css
in the <head>
section of your index.html
.
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
// highlight-start
<link href="/styles.css" rel="stylesheet">
// highlight-end
<title>TailwindElmishLand</title>
</head>
<body>
<div id="app"></div>
<script type="module" src=".elmish-land/App/App.fs.js"></script>
</body>
</html>
6. Configure import alias in tsconfig
Create a file named tsconfig.json
in the root folder of your project and add the following:
{
"files": [],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
}
}
7. Install shadcn/ui
npx shadcn@latest init
You will be asked a few questions to configure components.json.
8. Add Feliz.Shadcn
dotnet add package Feliz.Shadcn
9. That's it
You can now start adding components to your project.
npx shadcn@latest add button
The command above will add the Button component to your project. You can then use it in your pages like this:
module FelizShadcnIntro.Pages.Page
open Feliz
open ElmishLand
open FelizShadcnIntro.Shared
open FelizShadcnIntro.Pages
// highlight-start
open Feliz.Shadcn
// highlight-end
type Model = unit
type Msg =
| LayoutMsg of Layout.Msg
let init () =
(),
Command.none
let update (msg: Msg) (model: Model) =
match msg with
| LayoutMsg _ -> model, Command.none
let view (_model: Model) (_dispatch: Msg -> unit) =
// highlight-start
Html.div [
Shadcn.button [
prop.text "Click me"
prop.onClick (fun _ -> Browser.Dom.window.alert "Hello, shadcn/ui!")
]
]
// highlight-end
let page (_shared: SharedModel) (_route: HomeRoute) =
Page.from init update view () LayoutMsg
Run:
dotnet elmish-land server
to start your application.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Fable.Core (>= 3.7.1)
- Feliz (>= 2.8.0)
- FSharp.Core (>= 9.0.201)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.