Skip to main content
Ctrl+K
FSharp.ViewEngine · DesignFSharp.ViewEngine · Key FeaturesFSharp.ViewEngine · Quick ExampleFSharp.ViewEngine · Getting StartedCore installation · Using .NET CLICore installation · Using Paket CLICore installation · Runtime SupportCore installation · Source DebuggingCore installation · Next StepsBuild your first view · Create the viewBuild your first view · Render the viewBuild your first view · Reuse componentsBuild your first view · NextElements and attributes · ElementsElements and attributes · AttributesElements and attributes · Mixed contentElements and attributes · Generic escape hatchesComposition and control flow · Functions as componentsComposition and control flow · Conditional contentComposition and control flow · SequencesRendering · FragmentsRendering · DocumentsRendering · Application boundariesEncoding and trusted content · Encoded by defaultEncoding and trusted content · Trusted raw contentEncoding and trusted content · Trusted names and expressionsAccessibility · Prefer native HTMLAccessibility · Names and relationshipsAccessibility · ARIA coverageAccessibility · Test behaviorCustom Elements & Attributes · Trusted Content BoundariesCustom Elements & Attributes · Custom ElementsCustom Elements & Attributes · elCustom Elements & Attributes · elVoidCustom Elements & Attributes · Nested Web ComponentsCustom Elements & Attributes · Custom AttributesCustom Elements & Attributes · _attrCustom Elements & Attributes · Key-value attributeCustom Elements & Attributes · Boolean attributeCustom Elements & Attributes · Combining with Built-in AttributesCustom Elements & Attributes · Extending the Html TypeCustom Elements & Attributes · Adding Custom ElementsCustom Elements & Attributes · Adding Custom AttributesCustom Elements & Attributes · Design System ExampleCustom Elements & Attributes · Shoelace ExampleSVG · Support PolicySVG · SetupSVG · Element ReferenceSVG · Numeric and Length ValuesSVG · Icon ExampleSVG · Chart and Text ExampleSVG · Gradients, Clipping, Masking, and ReuseSVG · AccessibilitySVG · Linking and NamespacesSVG · Attribute ReferenceSVG · Unsupported SVGDatastar · SetupDatastar · Core AttributesDatastar · data-signalsDatastar · data-bindDatastar · data-computedDatastar · data-effectDatastar · data-showDatastar · data-textDatastar · data-attrDatastar · data-classDatastar · data-styleDatastar · data-initDatastar · data-onDatastar · data-on-intersectDatastar · data-on-intervalDatastar · data-on-signal-patchDatastar · data-on-signal-patch-filterDatastar · data-indicatorDatastar · data-refDatastar · data-json-signalsDatastar · data-ignoreDatastar · data-ignore-morphDatastar · data-preserve-attrDatastar · Pro AttributesDatastar · data-animateDatastar · data-custom-validityDatastar · data-match-mediaDatastar · data-on-rafDatastar · data-on-resizeDatastar · data-persistDatastar · data-query-stringDatastar · data-replace-urlDatastar · data-scroll-into-viewDatastar · data-view-transitionDatastar · Trusted ExpressionsDatastar · Content Security PolicyDatastar · Complete ExampleHTMX · SetupHTMX · Request MethodsHTMX · hx-getHTMX · hx-postHTMX · hx-putHTMX · hx-patchHTMX · hx-deleteHTMX · Request Data and ConfigurationHTMX · hx-encodingHTMX · hx-headersHTMX · hx-includeHTMX · hx-paramsHTMX · hx-requestHTMX · hx-valsHTMX · Targeting and SwappingHTMX · hx-targetHTMX · hx-selectHTMX · hx-select-oobHTMX · hx-swapHTMX · hx-swap-oobHTMX · hx-preserveHTMX · Requests in FlightHTMX · hx-indicatorHTMX · hx-disabled-eltHTMX · hx-syncHTMX · hx-validateHTMX · Triggering and InteractionHTMX · hx-triggerHTMX · hx-confirmHTMX · hx-promptHTMX · hx-onHTMX · Navigation and HistoryHTMX · hx-boostHTMX · hx-push-urlHTMX · hx-replace-urlHTMX · hx-historyHTMX · hx-history-eltHTMX · Inheritance and ProcessingHTMX · hx-disableHTMX · hx-disinheritHTMX · hx-inheritHTMX · hx-extHTMX · Generic and Deprecated AttributesHTMX · Complete ExampleAlpine.js · SetupAlpine.js · Core DirectivesAlpine.js · x-dataAlpine.js · x-initAlpine.js · x-showAlpine.js · x-bindAlpine.js · x-onAlpine.js · x-textAlpine.js · x-htmlAlpine.js · x-modelAlpine.js · x-modelableAlpine.js · x-forAlpine.js · x-transitionAlpine.js · x-effectAlpine.js · x-ignoreAlpine.js · x-refAlpine.js · x-cloakAlpine.js · x-teleportAlpine.js · x-ifAlpine.js · x-idAlpine.js · Plugin DirectivesAlpine.js · x-maskAlpine.js · x-intersectAlpine.js · x-resizeAlpine.js · x-collapseAlpine.js · x-trapAlpine.js · x-anchorAlpine.js · x-sortAlpine.js · Plugins Without Directive HelpersAlpine.js · Trusted ExpressionsAlpine.js · Complete ExampleTailwind Plus Elements · SetupTailwind Plus Elements · Shared AttributesTailwind Plus Elements · AutocompleteTailwind Plus Elements · Command PaletteTailwind Plus Elements · Copy ButtonTailwind Plus Elements · DialogTailwind Plus Elements · DisclosureTailwind Plus Elements · Dropdown MenuTailwind Plus Elements · PopoverTailwind Plus Elements · SelectTailwind Plus Elements · TabsTailwind Plus Elements · Runtime ReadinessComponents · Get startedComponents · ActionsComponents · FeedbackComponents · Data displayComponents · Form controlsComponents · NavigationComponents · OverlaysComponents · LayoutComponents · Code and diagramsComponent installation · Install the CLIComponent installation · Add componentsComponent installation · Install the build toolsComponent installation · Configure TailwindComponent installation · Import component JavaScriptComponent installation · Build and watchComponent installation · Serve and use the componentsComponent installation · Update installed componentsButton · InstallationButton · UsageButton · SizesButton · ColorsButton · VariantsButton · Uniform paddingButton · All color variantsButton · PendingButton · ChildrenButton · Icon-only variantsButton · Custom paletteButton · Primary buttonsButton · Secondary buttonsButton · Ghost buttonsButton · Native Ghost resetButton · Destructive buttonsButton · Destructive pendingButton · Disabled buttonsButton · Primary icon-onlyButton · Pending icon-onlyButton · Disabled icon-onlyButton · Datastar visibilityButton · Row actionsButton · Labels and focusButton · API referenceLink · InstallationLink · UsageLink · Text underlineLink · Inherited presentationLink · SizesLink · Uniform paddingLink · ColorsLink · VariantsLink · All color variantsLink · Icon-only variantsLink · Icon-only sizesLink · Native new-tab navigationLink · API referenceButton group · InstallationButton group · UsageButton group · Grouped actionsButton group · Native link segmentsButton group · Label and Select segmentsButton group · Custom controls and popup isolationButton group · Vertical orientationButton group · API referenceDropdown menu · InstallationDropdown menu · UsageDropdown menu · IconsDropdown menu · Keyboard hintsDropdown menu · CheckboxesDropdown menu · Radio choicesDropdown menu · Disabled itemsDropdown menu · Destructive actionDropdown menu · Outlined page actionDropdown menu · Custom native controlDropdown menu · Full context row and supporting descriptionsDropdown menu · Grouped states and refreshDropdown menu · Row actionsDropdown menu · API referenceToggle button · InstallationToggle button · UsageToggle button · PendingToggle button · DisabledToggle button · Content, sizes and variantsToggle button · API referenceToggle group · InstallationToggle group · UsageToggle group · Single selectionToggle group · Connected multiple and single-item groupsToggle group · Multiple, spaced and unavailableToggle group · SubmissionToggle group · Vertical orientationToggle group · API referenceBadge · InstallationBadge · UsageBadge · ColorsBadge · VariantsBadge · API referenceNotice · InstallationNotice · UsageNotice · ColorsNotice · VariantsNotice · Success with downloadNotice · WarningNotice · Error with recovery linkNotice · Announce an updateNotice · API referenceNotification · InstallationNotification · UsageNotification · Persistent with an actionNotification · Custom lifetimeNotification · AnnouncementsNotification · API referenceLoading indicator · InstallationLoading indicator · UsageLoading indicator · With visible labelLoading indicator · API referenceProgress · InstallationProgress · UsageProgress · IndeterminateProgress · CompleteProgress · FailedProgress · API referenceEmpty state · InstallationEmpty state · UsageEmpty state · Title onlyEmpty state · With recovery actionEmpty state · API referenceSkeleton · InstallationSkeleton · UsageSkeleton · TextSkeleton · Avatar rowSkeleton · CardSkeleton · Explicit dimensionsSkeleton · API referenceCallout · InstallationCallout · UsageCallout · API referenceIcon · InstallationIcon · UsageIcon · Heroicons familiesIcon · Brand logosIcon · Rendered-size overridesIcon · API referenceTable · InstallationTable · UsageTable · Comfortable rowsTable · Hover highlightingTable · With status valuesTable · With checkboxesTable · Scrollable rows and sticky headingsTable · Stacked on mobileTable · Sortable recordsTable · Hierarchical itemsTable · Row actionsTable · Empty stateTable · Infinite scrollTable · API referenceChart · InstallationChart · UsageChart · ColumnChart · Horizontal barChart · SankeyChart · Updating options and handling eventsChart · Empty dataChart · API referenceDescription list · InstallationDescription list · UsageDescription list · Three-column detailsDescription list · Four-column detailsDescription list · With supporting textDescription list · API referenceMetric · InstallationMetric · UsageMetric · With trend and statusMetric · With review statusMetric · Multiple metricsMetric · API referenceAvatar · InstallationAvatar · UsageAvatar · Fallbacks and sizesAvatar · ImageAvatar · Image unavailableAvatar · DecorativeAvatar · API referenceCopy and reveal · InstallationCopy and reveal · UsageCopy and reveal · Icon actionsCopy and reveal · Initially revealedCopy and reveal · API referenceDay calendar · InstallationDay calendar · UsageDay calendar · Overlapping sessionsDay calendar · Compact controlsDay calendar · Provisional time selectionDay calendar · API referenceWeek calendar · InstallationWeek calendar · UsageWeek calendar · Events and date navigationWeek calendar · Shared controls and event detailsWeek calendar · API referenceMonth calendar · InstallationMonth calendar · UsageMonth calendar · Events and date navigationMonth calendar · Compact monthMonth calendar · Single-date selectionMonth calendar · Clearable single dateMonth calendar · Current dateMonth calendar · Today shortcutMonth calendar · Date rangeMonth calendar · Bounds, unavailable dates and Monday startMonth calendar · Month and year selectorsMonth calendar · Busy availabilityMonth calendar · Read-only selectionMonth calendar · API referenceYear calendar · InstallationYear calendar · UsageYear calendar · Event indicators and date navigationYear calendar · API referenceKbd · InstallationKbd · UsageKbd · Shortcut groupKbd · API referenceSeparator · InstallationSeparator · UsageSeparator · Orientation and semanticsSeparator · API referenceCard · InstallationCard · UsageCard · Header and footerCard · With mediaCard · API referenceMessage · InstallationMessage · UsageMessage · Sender and receiverMessage · Metadata and actions without an avatarMessage · API referenceInput · InstallationInput · UsageInput · Consistent control sizesInput · With help textInput · RequiredInput · OptionalInput · Validation errorInput · Native searchInput · DisabledInput · Read-onlyInput · API referenceInput group · InstallationInput group · UsageInput group · IconInput group · SuffixInput group · Text addonsInput group · Icon and keyboard hintInput group · Addon popup keeps its own controlsInput group · Textarea header and footerInput group · Validation errorInput group · Checking with visible feedbackInput group · API referenceField · InstallationField · UsageField · Custom controlField · Responsive label and control rowsField · Semantic fieldsetField · Labels and focusField · API referenceTextarea · InstallationTextarea · UsageTextarea · Visually hidden labelTextarea · With instructionsTextarea · Validation errorTextarea · Read-onlyTextarea · DisabledTextarea · API referenceFile selection · InstallationFile selection · UsageFile selection · Multiple filesFile selection · ValidationFile selection · DisabledFile selection · API referenceTag input · InstallationTag input · UsageTag input · SubmissionTag input · ValidationTag input · PendingTag input · DisabledTag input · API referenceError summary · InstallationError summary · UsageError summary · API referenceSelect · InstallationSelect · UsageSelect · Custom items and groupsSelect · Multiple selectionSelect · Local searchSelect · Remote searchSelect · Form validationSelect · DisabledSelect · PendingSelect · API referenceTime picker · InstallationTime picker · UsageTime picker · 24-hour display and boundsTime picker · Disabled and read-onlyTime picker · API referenceDate picker · InstallationDate picker · UsageDate picker · Clearable single dateDate picker · Current dateDate picker · Today shortcutDate picker · Date rangeDate picker · Month and year selectorsDate picker · Bounds and unavailable datesDate picker · ValidationDate picker · PendingDate picker · DisabledDate picker · Read-onlyDate picker · API referenceCheckbox · InstallationCheckbox · UsageCheckbox · With help textCheckbox · IndeterminateCheckbox · Required confirmation with validationCheckbox · CheckedCheckbox · PendingCheckbox · DisabledCheckbox · API referenceSwitch · InstallationSwitch · UsageSwitch · With help textSwitch · Setting with submissionSwitch · PendingSwitch · DisabledSwitch · Validation errorSwitch · SizesSwitch · Stacked layoutSwitch · API referenceRadio group · InstallationRadio group · UsageRadio group · Option descriptionsRadio group · Horizontal orientationRadio group · Required choice with validationRadio group · PendingRadio group · DisabledRadio group · API referenceChoice cards · InstallationChoice cards · UsageChoice cards · Single choiceChoice cards · Multiple choicesChoice cards · ValidationChoice cards · API referenceField group · InstallationField group · UsageField group · Without descriptionField group · Disabled fieldsetField group · Horizontal fieldsField group · Responsive fieldsField group · API referenceBreadcrumbs · InstallationBreadcrumbs · UsageBreadcrumbs · Middle overflowBreadcrumbs · Available spaceBreadcrumbs · API referenceSide nav · InstallationSide nav · UsageSide nav · Sections and collapsible groupsSide nav · Header, context, content and footerSide nav · Nested navigation with badges and actionsSide nav · Expansion and scrollSide nav · API referenceTabs · InstallationTabs · UsageTabs · Server-owned selectionTabs · Underlined tabs with refreshTabs · Vertical, icons and disabled itemsTabs · API referencePagination · InstallationPagination · UsagePagination · Page navigationPagination · Numbers onlyPagination · Previous and next onlyPagination · API referenceCommand · InstallationCommand · UsageCommand · Groups, icons and shortcutsCommand · Contextual page linksCommand · Actions and disabled itemsCommand · Dialog paletteCommand · Empty resultsCommand · API referenceBottom navigation · InstallationBottom navigation · UsageBottom navigation · Four destinationsBottom navigation · Three destinationsBottom navigation · API referenceDialog · InstallationDialog · UsageDialog · Modal dialogDialog · Server-validated confirmationDialog · App-contained dialogDialog · Labels and focusDialog · API referenceDrawer · InstallationDrawer · UsageDrawer · NavigationDrawer · Standard detail drawerDrawer · Wide editing formDrawer · Start-side filtersDrawer · Top and bottom edgesDrawer · App-contained drawerDrawer · Labels and focusDrawer · API referenceFloating panel · InstallationFloating panel · UsageFloating panel · Minimized with restoreFloating panel · ChecklistFloating panel · API referencePopover · InstallationPopover · UsagePopover · With formPopover · Side and alignmentPopover · Custom native triggerPopover · API referenceTooltip · InstallationTooltip · UsageTooltip · Existing descriptionTooltip · Bottom placementTooltip · API referenceBrowser · InstallationBrowser · UsageBrowser · With an address barBrowser · Review controls and expansionBrowser · API referencePhone · InstallationPhone · UsagePhone · With screen contentPhone · Review controls and expansionPhone · API referenceResizable · InstallationResizable · UsageResizable · Horizontal split panelsResizable · Vertical split panelsResizable · API referenceSlide · InstallationSlide · UsageSlide · CoverSlide · API referencePresentation · InstallationPresentation · UsagePresentation · API referencePage header · InstallationPage header · UsagePage header · Title and page actionsPage header · API referenceSection header · InstallationSection header · UsageSection header · Description, actions and dividerSection header · API referenceSection · InstallationSection · UsageSection · Section spacingSection · API referenceDisclosure · InstallationDisclosure · UsageDisclosure · API referencePage top bar · InstallationPage top bar · UsagePage top bar · Full-width shell barPage top bar · API referenceCode block · InstallationCode block · Quick start with GiraffeCode block · Add syntax highlightingCode block · Optional Prism stylesheetCode block · F#Code block · PythonCode block · TypeScriptCode block · BashCode block · SQLCode block · Optional nonce CSPCode block · API referenceExample · InstallationExample · UsageExample · API referenceMermaid · InstallationMermaid · UsageMermaid · Sequence constructorsMermaid · API referenceF# API reference · InstallationF# API reference · UsageF# API reference · API referenceStandalone F# scripts · PrerequisitesStandalone F# scripts · Use the Core packageStandalone F# scripts · Install editable components into a scriptStandalone F# scripts · Compose the HTML pageStandalone F# scripts · Build and viewStandalone F# scripts · Keep source ownership explicitStandalone F# scripts · Next stepsGiraffe integration · Minimal ExampleGiraffe integration · How It WorksGiraffe integration · Title ElementsUsing signals · Bind a value and handle an actionUsing signals · Related examplesTheming · Apply a theme to a regionTheming · Override only what you needTheming · Scope CSS variables to a regionTheming · CSS-variable referenceTheming · Internal variablesTheming · Add an appearance pickerTheming · Theme APIBuild a presentation · Create a deckBuild a presentation · Compose slides with ordinary F#Build a presentation · Build and openBuild a presentation · Present in the browserBuild a presentation · Print or save as PDFBuild a presentation · Explore the complete exampleBenchmarks · Rendering performanceBenchmarks · EnvironmentBenchmarks · ReproduceExamples · Templates

Standalone F# scripts

Author HTML in F# and use dotnet fve build to render the page, compile its styles and JavaScript, and open it in your browser. No web server is required.

On this page

Prerequisites

Use a .NET 11 SDK and Node.js 20 or newer with npm for CLI builds. FVE installs and caches its pinned Tailwind and esbuild tools automatically; no per-page npm project or manual frontend-tool installation is needed.

SDK 10 and 11 are actively tested for script execution; use SDK 11 for new scripts. SDK selection is separate from Core’s net8.0 compatibility asset. If a parent directory selects an older SDK, select SDK 11 in a script-local global.json before running the script.

Use the Core package

A script can reference the pinned Core package directly and render ordinary typed HTML:

#r "nuget: FSharp.ViewEngine, 2026.8.2"
open System.IO
open FSharp.ViewEngine
open type Html

let document =
    html {
        _lang "en"
        head { title { "A standalone page" } }
        body { h1 { "Built with F#" } }
    }

File.WriteAllText(Path.Combine(__SOURCE_DIRECTORY__, "page.html"), Render.toHtmlDocString document)
dotnet fsi page.fsx

Install editable components into a script

Use a local tool manifest to pin the CLI. Run these commands in a new directory. Script consumers use the same registry, dependency resolution and editable-source protections as project consumers:

dotnet new globaljson --sdk-version 11.0.100 --roll-forward latestFeature
dotnet new tool-manifest
dotnet tool install FSharp.ViewEngine.Cli
dotnet fve init page.fsx
dotnet fve add card

The CLI creates page.fsx and fve.json, pins the Core reference, and writes one dependency-ordered #load directive in a managed block. Keep that block; it opens the configured component namespace. The namespace defaults to the script filename without its extension (page here), with hyphens and spaces replaced by underscores. Use the optional --namespace MyApp.Components override only when you want a different source namespace. Installation does not compile a DLL or require an .fsproj. A new script also gets an editable input.css and matching CSS/JavaScript references in its HTML shell. Build does not rewrite those authored inputs. Existing content outside the block is preserved. When initializing an existing script, remove its old manual FSharp.ViewEngine #r first so the CLI can own that single pinned reference.

Compose the HTML page

Replace the starter document below the managed block with ordinary HTML and an editable Card component:

open System.IO
open FSharp.ViewEngine
open type Html

let document =
    html {
        _lang "en"
        head {
            meta { _charset "utf-8" }
            meta { _name "viewport"; _content "width=device-width, initial-scale=1" }
            title { "A standalone page" }
            link { _rel "stylesheet"; _href "page.css" }
        }
        body {
            _class (ComponentsTheme.className ComponentsTheme.sky + " m-0 bg-[var(--fve-background)] p-6 text-[var(--fve-text)]")
            main {
                _class "mx-auto max-w-xl"
                fveCard {
                    fveCardHeader {
                        h1 { _class "m-0 text-2xl font-semibold"; "Built with F#" }
                    }
                    p { "This page uses editable component source and opens directly from disk." }
                }
            }
            script { _src "page.js" }
        }
    }

File.WriteAllText(Path.Combine(__SOURCE_DIRECTORY__, "page.html"), Render.toHtmlDocString document)

Build and view

Build renders the script, compiles input.css, and bundles the installed components’ browser modules into matching HTML, CSS and JavaScript files. Use --open to view the finished HTML in your default browser:

dotnet fve build --open

Init creates input.css with these source scans. Keep it editable; add @source entries for shared files outside the script directory when needed:

@import "tailwindcss" source(none);
@source "./**/*.fs";
@source "./**/*.fsx";
@source "./Components/Assets/*.js";

The command reads the entry script from fve.json; use --config path/to/fve.json when building from another directory. Treat page.html, page.css and page.js as generated outputs. Build uses edited installed components without reinstalling or upgrading them. Keep the generated assets, local images and fonts beside the HTML and use relative paths. Application projects continue to use dotnet build.

Keep source ownership explicit

dotnet fve diff
dotnet fve add card --overwrite

Use diff before updating. Reinstalling without overwrite preserves edited component source; changing or removing a managed script block fails before any source writes. Use overwrite only when replacing that managed content is intended. Rendered script values are encoded as normal FVE text; raw remains an explicit trusted-markup escape hatch.