Skip to main content

NavigationView

A Fluent navigation view: the layout of a Windows app, with a pane of pages to navigate between and the content of the selected page.

The view fills the space it is given: give it a size or expand=True.

Example:

fluent.NavigationView(
expand=True,
selected_index=0,
items=[
fluent.PaneItem(
"Home",
icon=fluent.FluentIcons.HOME,
content=fluent.ScaffoldPage(content=ft.Text("Welcome home")),
),
fluent.PaneItem(
"Mail",
icon=fluent.FluentIcons.MAIL,
content=fluent.ScaffoldPage(content=ft.Text("No new mail")),
),
],
footer_items=[
fluent.PaneItem(
"Settings",
icon=fluent.FluentIcons.SETTINGS,
content=fluent.ScaffoldPage(content=ft.Text("Settings")),
),
],
)
NavigationView
NavigationView

Inherits: LayoutControl

Properties

Events

  • on_change - Called when the user selects another page.

Example​

Fluent NavigationView​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


def page_for(title: str, text: str) -> fluent.ScaffoldPage:
return fluent.ScaffoldPage(
header=fluent.PageHeader(title=title),
content=ft.Text(text),
)


def main(page: ft.Page):
page.title = "Fluent NavigationView"
page.padding = 0

page.add(
fluent.NavigationView(
expand=True,
selected_index=0,
header="Mail",
items=[
fluent.PaneItem(
"Inbox",
icon=fluent.FluentIcons.MAIL_INBOX,
info_badge=fluent.InfoBadge("3"),
content=page_for("Inbox", "You have 3 unread messages."),
),
fluent.PaneItem(
"Sent",
icon=fluent.FluentIcons.SEND,
content=page_for("Sent", "Messages you sent."),
),
fluent.PaneItemSeparator(),
fluent.PaneItemHeader("Folders"),
fluent.PaneItem(
"Archive",
icon=fluent.FluentIcons.ARCHIVE,
content=page_for("Archive", "Archived messages."),
),
],
footer_items=[
fluent.PaneItem(
"Settings",
icon=fluent.FluentIcons.SETTINGS,
content=page_for("Settings", "Mail settings."),
),
],
)
)


if __name__ == "__main__":
ft.run(main)
navigation_view
Opening the compact pane to go to Archive, then to Settings

Properties​

display_modeclass-attributeinstance-attribute​

How the pane is shown.

footer_itemsclass-attributeinstance-attribute​

footer_items: list[Control] = field(default_factory=list)

The items at the bottom of the pane, such as Settings.

headerclass-attributeinstance-attribute​

header: StrOrControl | None = None

A title or control shown at the top of the pane.

itemsclass-attributeinstance-attribute​

items: list[Control] = field(default_factory=list)

The items at the top of the pane: PaneItem, PaneItemHeader and PaneItemSeparator controls.

selected_indexclass-attributeinstance-attribute​

selected_index: int | None = None

The index of the selected page.

Pages are the PaneItem controls that have content, counted in the order they appear: items (including the items inside expandable items), then footer_items. Headers, separators and items without content are not counted.

If None, no page is selected and the content area is empty.

Events​

on_changeclass-attributeinstance-attribute​

on_change: ControlEventHandler[NavigationView] | None = (
    None
)

Called when the user selects another page.

selected_index holds the index of the new page.