Skip to content
Navigation NavigationMenu

NavigationMenu

Links with an active state taken from the address; sub-items open in a panel or a collapsible group.

On this page

Examples

Horizontal

A disclosure pattern, not role=menu.

Razor
<KlyNavigationMenu Items="Items" AriaLabel="Primary" />

@code {
    private static readonly KlyNavigationItem[] Items =
    [
        new("Home") { Href = "/", Exact = true },
        new("Components")
        {
            Children =
            [
                new("Button") { Href = "/components/button" },
                new("Tabs") { Href = "/components/tabs" },
                new("Tree") { Href = "/components/tree" },
            ],
        },
        new("Docs") { Href = "/docs" },
    ];
}

Vertical

Razor
<div class="w-64">
    <KlyNavigationMenu Items="Items" Orientation="KlyOrientation.Vertical" AriaLabel="Sidebar" />
</div>

@code {
    private static readonly KlyNavigationItem[] Items =
    [
        new("Home") { Href = "/", Exact = true },
        new("Guides")
        {
            Children =
            [
                new("Installation") { Href = "/docs/installation" },
                new("Theming") { Href = "/docs/theming" },
            ],
        },
        new("Render modes") { Href = "/docs/render-modes" },
    ];
}

API

KlyNavigationMenu

Site navigation of links with optional sub-items, horizontal or vertical, with the current page marked.

Parameters

Name Type Default Description
AriaLabel string Accessible name of the navigation landmark. Needed when the page has several.
Class string Classes added to the root element, merged last so they win over the theme.
Color KlyColor "primary" Semantic color of the navigation menu: a built-in KlyColor or the name of a color you defined. When not set, Color applies, else the default of the component. Values: primary, secondary, success, info, warning, error, neutral.
Items (required) IReadOnlyList<KlyNavigationItem> The links, with optional sub-items, as KlyNavigationItem .
Orientation KlyOrientation KlyOrientation.Horizontal Horizontal opens sub-items in a popover; Vertical shows them as collapsible groups. Values: Horizontal, Vertical.
Ui NavigationMenuUi Per-instance class overrides of the slots of the navigation menu, see NavigationMenuUi . They are merged after the theme and the Class parameter wins on the root slot.

Ui slots

Ui takes a NavigationMenuUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyNavigationMenu , after the theme and the app configuration.
List Classes merged into the list slot of KlyNavigationMenu , after the theme and the app configuration.
Item Classes merged into the item slot of KlyNavigationMenu , after the theme and the app configuration.
Link Classes merged into the link slot of KlyNavigationMenu , after the theme and the app configuration.
Trigger Classes merged into the trigger slot of KlyNavigationMenu , after the theme and the app configuration.
Icon Classes merged into the icon slot of KlyNavigationMenu , after the theme and the app configuration.
Label Classes merged into the label slot of KlyNavigationMenu , after the theme and the app configuration.
Chevron Classes merged into the chevron slot of KlyNavigationMenu , after the theme and the app configuration.
Panel Classes merged into the panel slot of KlyNavigationMenu , after the theme and the app configuration.
PanelList Classes merged into the panelList slot of KlyNavigationMenu , after the theme and the app configuration.
Group Classes merged into the group slot of KlyNavigationMenu , after the theme and the app configuration.
GroupList Classes merged into the groupList slot of KlyNavigationMenu , after the theme and the app configuration.