Skip to main content

CommandBar

A Fluent command bar: a toolbar of commands, with a "More" menu for commands that are used less often or don't fit.

Example:

fluent.CommandBar(
primary_items=[
fluent.CommandBarButton(icon=fluent.FluentIcons.ADD, content="New"),
fluent.CommandBarButton(
icon=fluent.FluentIcons.DELETE, content="Delete"
),
fluent.CommandBarSeparator(),
fluent.CommandBarButton(icon=fluent.FluentIcons.SHARE, content="Share"),
],
secondary_items=[
fluent.CommandBarButton(
icon=fluent.FluentIcons.SETTINGS, content="Settings"
),
],
)
CommandBar
CommandBar

Inherits: LayoutControl

Properties

Example​

Fluent CommandBar​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


def main(page: ft.Page):
page.title = "Fluent CommandBar"

def handle_click(e: ft.Event[fluent.CommandBarButton]):
status.value = f"{e.control.content} clicked"

status = ft.Text("Pick a command")

page.add(
ft.SafeArea(
content=ft.Column(
controls=[
fluent.CommandBar(
card=True,
primary_items=[
fluent.CommandBarButton(
icon=fluent.FluentIcons.ARROW_REPLY,
content="Reply",
on_click=handle_click,
),
fluent.CommandBarButton(
icon=fluent.FluentIcons.ARROW_FORWARD,
content="Forward",
on_click=handle_click,
),
fluent.CommandBarSeparator(),
fluent.CommandBarButton(
icon=fluent.FluentIcons.ARCHIVE,
content="Archive",
on_click=handle_click,
),
fluent.CommandBarButton(
icon=fluent.FluentIcons.DELETE,
content="Delete",
on_click=handle_click,
),
],
secondary_items=[
fluent.CommandBarButton(
icon=fluent.FluentIcons.FLAG,
content="Flag",
on_click=handle_click,
),
fluent.CommandBarButton(
icon=fluent.FluentIcons.MAIL_READ,
content="Mark as read",
on_click=handle_click,
),
],
),
status,
],
)
)
)


if __name__ == "__main__":
ft.run(main)
command_bar
Archiving, then marking as read from the More menu

Properties​

alignmentclass-attributeinstance-attribute​

How the commands are placed along the bar.

cardclass-attributeinstance-attribute​

card: bool = False

Whether the bar is shown on a card: a rounded background with a border.

compactclass-attributeinstance-attribute​

compact: bool = False

Whether the bar shows only the icons of commands that have one.

overflow_behaviorclass-attributeinstance-attribute​

What happens when primary_items don't fit in the bar.

primary_itemsclass-attributeinstance-attribute​

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

The commands shown in the bar: CommandBarButton and CommandBarSeparator controls.

Other controls, such as a search box, are shown as they are.

secondary_itemsclass-attributeinstance-attribute​

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

The commands shown in the "More" menu, which opens from a "..." button at the end of the bar.