Skip to content

OverlayVisibilityMode

Visibility of text field overlays based on the state of the current text entry.

Inherits: Enum

Properties

  • ALWAYS

    Always show the overlay regardless of the text entry state.

  • EDITING

    Overlay will only appear when the current text entry is not empty.

  • NEVER

    Overlay will never appear regardless of the text entry state.

  • NOT_EDITING

    Overlay will only appear when the current text entry is empty.

Examples#

Showcase#

import flet as ft


def showcase_card(mode: ft.OverlayVisibilityMode) -> ft.Container:
    return ft.Container(
        width=380,
        padding=12,
        border=ft.Border.all(1, ft.Colors.RED),
        border_radius=10,
        bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
        content=ft.Column(
            spacing=8,
            controls=[
                ft.Text(mode.name, weight=ft.FontWeight.BOLD),
                ft.Text("Prefix/suffix visibility (prefilled):", size=11),
                ft.CupertinoTextField(
                    value="Flet",
                    placeholder_text="Search",
                    prefix=ft.Icon(ft.CupertinoIcons.SEARCH),
                    suffix=ft.Icon(ft.CupertinoIcons.MIC),
                    prefix_visibility_mode=mode,
                    suffix_visibility_mode=mode,
                ),
                ft.Text("Clear button visibility:", size=11),
                ft.CupertinoTextField(
                    value="Clear me",
                    placeholder_text="Type text",
                    clear_button_visibility_mode=mode,
                ),
            ],
        ),
    )


def main(page: ft.Page):
    page.theme_mode = ft.ThemeMode.DARK
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

    page.appbar = ft.AppBar(title="OverlayVisibilityMode Showcase")
    page.add(
        ft.Text("Compare when Cupertino text field overlays appear."),
        ft.Row(
            wrap=True,
            spacing=12,
            expand=True,
            scroll=ft.ScrollMode.AUTO,
            alignment=ft.MainAxisAlignment.CENTER,
            controls=[showcase_card(mode) for mode in ft.OverlayVisibilityMode],
        ),
    )


ft.run(main)

Properties#

ALWAYS = 'always' class-attribute instance-attribute #

Always show the overlay regardless of the text entry state.

EDITING = 'editing' class-attribute instance-attribute #

Overlay will only appear when the current text entry is not empty.

This includes prefilled text that the user did not type in manually. But does not include text in placeholders.

NEVER = 'never' class-attribute instance-attribute #

Overlay will never appear regardless of the text entry state.

NOT_EDITING = 'notEditing' class-attribute instance-attribute #

Overlay will only appear when the current text entry is empty.

This also includes not having prefilled text that the user did not type in manually. Texts in placeholders are ignored.