Skip to main content

ContentDialog

A Fluent dialog: a window over the page that the user must deal with before going back to it.

Open it with Page.show_dialog and close it with Page.pop_dialog, like AlertDialog.

Example:

page.show_dialog(
fluent.ContentDialog(
title="Delete file?",
content="The file will be deleted permanently.",
actions=[
fluent.FilledButton("Delete", on_click=delete),
fluent.Button("Cancel", on_click=lambda e: page.pop_dialog()),
],
)
)
ContentDialog
ContentDialog

Inherits: DialogControl

Properties

  • actions - The buttons shown at the bottom, usually Button and FilledButton controls.
  • content - The main content of this dialog.
  • modal - Whether the dialog stays open when the user clicks outside it.
  • open
  • title - The title of this dialog.

Example​

Fluent ContentDialog​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


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

def delete(e: ft.Event[fluent.FilledButton]):
page.pop_dialog()
# pop_dialog() sends its own update, so the page is not auto-updated
# after this handler; send the status change explicitly.
status.value = "File deleted"
status.update()

def cancel(e: ft.Event[fluent.Button]):
page.pop_dialog()
status.value = "Kept the file"
status.update()

dialog = fluent.ContentDialog(
title="Delete file?",
content="If you delete this file, you won't be able to recover it.",
actions=[
fluent.FilledButton("Delete", on_click=delete),
fluent.Button("Cancel", on_click=cancel),
],
)

status = ft.Text()

page.add(
ft.SafeArea(
content=ft.Column(
controls=[
fluent.Button(
"Delete file", on_click=lambda e: page.show_dialog(dialog)
),
status,
],
)
)
)


if __name__ == "__main__":
ft.run(main)
content_dialog
Deleting a file

Properties​

actionsclass-attributeinstance-attribute​

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

The buttons shown at the bottom, usually Button and FilledButton controls. They share the width of the dialog equally.

contentclass-attributeinstance-attribute​

content: StrOrControl | None = None

The main content of this dialog.

modalclass-attributeinstance-attribute​

modal: bool = True

Whether the dialog stays open when the user clicks outside it.

The dialog can be closed with Esc either way.

openclass-attributeinstance-attribute​

open: bool = field(default=False, kw_only=True)

titleclass-attributeinstance-attribute​

title: StrOrControl | None = None

The title of this dialog.