Side nav
Compose optional header, context, scrolling content and footer slots. Use SideNavItem for links, SideNavSection for static headings, and SideNavGroup for collapsible groups. SideNavRow links have no default trailing indicator; menu rows retain a downward chevron. Add an avatar with withLeading, secondary text or email with withDescription, and optional trailing content with withTrailing. Sections use small, muted labels without indentation, and groups guide nested children with vertical lines.
Default
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
type DefaultSideNavDestination =
| Overview
| Settings
let defaultSideNavUrl =
function
| Overview -> "/components/side-nav"
| Settings -> "/guides/theming"
let defaultSideNav =
fveSideNav {
_id "default-side-navigation"
_ariaLabel "Primary navigation"
fveSideNavContent {
fveSideNavItem {
_href (defaultSideNavUrl Overview)
"Overview"
}
fveSideNavItem {
_href (defaultSideNavUrl Settings)
"Settings"
}
}
}
// Resolve your destination values to URLs.On this page
Installation
Copy this component and its required dependencies into the consumer-owned Components project.
dotnet fve add side-nav --config src/Acme.Components/fve.jsonAdd to src/Acme.Web/js/app.js once, alongside your other component imports:
import '../../Acme.Components/Components/Assets/dropdown-menu.js';
import '../../Acme.Components/Components/Assets/side-nav.js';The CLI resolves dependencies and preserves consumer-authored files. See Installation for project initialization, Tailwind, the shared runtime, and building/loading your app entry.
Usage
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
type DefaultSideNavDestination =
| Overview
| Settings
let defaultSideNavUrl =
function
| Overview -> "/components/side-nav"
| Settings -> "/guides/theming"
let defaultSideNav =
fveSideNav {
_id "default-side-navigation"
_ariaLabel "Primary navigation"
fveSideNavContent {
fveSideNavItem {
_href (defaultSideNavUrl Overview)
"Overview"
}
fveSideNavItem {
_href (defaultSideNavUrl Settings)
"Settings"
}
}
}
// Resolve your destination values to URLs.Expansion and scroll
Groups stay independently open or closed during navigation, history and refresh. Their initial state opens the active branch; remembered choices take precedence, including an explicit collapse of that branch. Content scroll is also remembered for the current browser tab.
Preferences use sessionStorage and default to the stable SideNav ID. Use _persistenceKey to separate unrelated navigation trees that reuse an ID, or to share preferences between responsive presentations of one tree. Give groups stable _id values when their order changes; otherwise their structural position and label identify them.
Include SideNavPreferences.assetsWithNonce once in the document head before the application module to restore saved disclosures before the first paint. Pass the host's CSP nonce, or use SideNavPreferences.assets() when no nonce is required. The initializer also preserves native toggles made while the application module is loading.
head {
SideNavPreferences.assetsWithNonce (Some nonce)
// Your stylesheet and application module follow.
}_expandedSignal keeps the host responsible for initializing and persisting that group's state. When storage is unavailable, toggles still work in the current document. Without JavaScript, native links and details/summary retain their server-rendered defaults, but browser preferences are not restored.
API reference
type SideNavWidth =
| Narrow
| Standard
| Wide
module SideNavPreferences =
val assetsWithNonce : nonce:string option -> HtmlElement
val assets : HtmlElement
module SideNavDsl =
val fveSideNav : ComponentElementBuilder
val fveSideNavHeader : ComponentElementBuilder
val fveSideNavHeaderCompact : ComponentElementBuilder
val fveSideNavContent : ComponentElementBuilder
val fveSideNavContext : ComponentElementBuilder
val fveSideNavMobileContext : ComponentElementBuilder
val fveSideNavFooter : ComponentElementBuilder
val fveSideNavCompactFooter : ComponentElementBuilder
val fveSideNavItem : ComponentElementBuilder
val fveSideNavGroup : ComponentElementBuilder
val fveSideNavSection : ComponentElementBuilder
val fveSideNavRow : ComponentElementBuilder
val fveSideNavLeading : ComponentElementBuilder
val fveSideNavBadge : ComponentElementBuilder
val fveSideNavAction : ComponentElementBuilder
val fveSideNavTrailing : ComponentElementBuilder
module SideNavAttributes =
val Html._width.Static : value:SideNavWidth -> HtmlAttribute
val Html._expandedSignal.Static : value:string -> HtmlAttribute