Installation
Install editable components with the CLI, then build their Tailwind stylesheet and browser modules.
On this page
Install the CLI
For NuGet setup and supported .NET versions, see Core installation.
Start with a .NET web project and Node.js LTS with npm. Run these commands from your repository root:
dotnet new tool-manifest
dotnet tool install FSharp.ViewEngine.Cli
dotnet tool restoreAdd components
dotnet fve init src/Acme.Components/Acme.Components.fsproj --namespace Acme.Components
dotnet fve add button field input --config src/Acme.Components/fve.json
dotnet add src/Acme.Web/Acme.Web.fsproj reference src/Acme.Components/Acme.Components.fsprojThe CLI copies F# source, component JavaScript and required runtime assets. Commit the installed source, fve.json and tool manifest.
Install the build tools
Install Tailwind CSS, its CLI and Typography plugin, and esbuild together in your web project:
cd src/Acme.Web
npm init -y
npm install --save-dev tailwindcss@4 @tailwindcss/cli@4 @tailwindcss/typography esbuildRun the remaining npm commands from this directory. Commit package.json and package-lock.json; use npm ci on subsequent installs.
Configure Tailwind
Create src/Acme.Web/input.css. Scan your views and the installed F# and JavaScript so Tailwind includes the components' styles:
@import "tailwindcss" source(none);
@plugin "@tailwindcss/typography";
@custom-variant dark (&:where(.dark, .dark *));
@source "../Acme.Components/Components/**/*.fs";
@source "../Acme.Components/Components/Assets/**/*.js";
@source not "../Acme.Components/Components/Assets/echarts.6.1.0.esm.min.js";
@source "./**/*.fs";Import component JavaScript
Create src/Acme.Web/js/app.js. Import the shared runtime once, then add the imports shown in each component's Installation section. For Button:
import '../../Acme.Components/Components/Assets/datastar-rocket.1.0.4.js';
import '../../Acme.Components/Components/Assets/button.js';The installed Rocket runtime includes Datastar. No separate Datastar installation or script is needed.
If none of your installed components need JavaScript, skip the module entry, JavaScript build, and script tag.
Build and watch
Keep build inputs outside wwwroot. Serve only browser-ready files from wwwroot/js, wwwroot/css, wwwroot/fonts and wwwroot/images. This recipe uses esbuild; browser-ready modules can also be served directly. Add these scripts to your web project's package.json:
{
"scripts": {
"build:css": "tailwindcss -i input.css -o wwwroot/css/output.css --minify",
"build:js": "esbuild js/app.js --bundle --format=esm --splitting --outdir=wwwroot/js --minify",
"watch:css": "npm run build:css -- --watch",
"watch:js": "npm run build:js -- --watch"
}
}npm run build:css
npm run build:jsDuring development, run npm run watch:css and npm run watch:js in separate terminals alongside your .NET host.
Serve and use the components
Enable static files in your host (for example, app.UseStaticFiles() with ASP.NET Core). Load the stylesheet and, for interactive components, the module once. Apply a component theme to the owning region:
open FSharp.ViewEngine
open Acme.Components
open type Html
let page =
html {
head {
title { "My application" }
meta { _charset "utf-8" }
meta { _name "viewport"; _content "width=device-width, initial-scale=1" }
link { _rel "stylesheet"; _href "/css/output.css" }
script { _type "module"; _src "/js/app.js" }
}
body {
for attribute in ComponentsTheme.attributes ComponentsTheme.sky do attribute
fveButton { _color Color.Primary; _variant ButtonVariant.Solid; "Save" }
}
}See the full Application example to try the components in a running app and browse its source.
Update installed components
dotnet tool update FSharp.ViewEngine.Cli
dotnet fve diff --config src/Acme.Components/fve.jsonThe tool manifest pins the registry version. Review the diff before updating installed source: fve add preserves local edits; --overwrite replaces them only when you explicitly choose it. Commit the tool manifest and installed source together.