Skip to main content

CupertinoBottomSheet

An iOS-style popup that slides up from the bottom of the screen, with the page dimmed behind it.

Open it with Page.show_dialog and close it with Page.pop_dialog.

content is shown as it is, so a control that draws its own surface, such as a CupertinoActionSheet, keeps its look.

Setting height, padding or bgcolor places content on a sheet: a box with a background that stays above the on-screen keyboard and the bottom safe area. Use it for a picker, such as CupertinoDatePicker, which fills all the height it is given, and for content with a text field, which the keyboard would otherwise cover.

Example:

page.show_dialog(
ft.CupertinoBottomSheet(
height=216,
padding=ft.Padding.only(top=6),
content=ft.CupertinoDatePicker(),
)
)

Inherits: DialogControl

Properties

  • bgcolor - The background color of the sheet.
  • content - The control to be displayed in this bottom sheet.
  • height - The height of the sheet.
  • modal - Whether this bottom sheet stays open when the user taps outside of it.
  • open
  • padding - The padding between the sheet's edges and content.

Examples​

Picker with a toolbar​

A height places the content on a sheet, so it can hold any layout: here a CupertinoDatePicker under a Cancel/Done toolbar. Done shows the chosen date and closes the sheet; Cancel only closes it.

Sourceplay_arrowTry Online
from datetime import datetime

import flet as ft


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

def handle_done(e: ft.Event[ft.CupertinoButton]):
selection.value = f"Selected date: {date_picker.value:%B %d, %Y}"
selection.update()
page.pop_dialog()

date_picker = ft.CupertinoDatePicker(
value=datetime.now(),
date_picker_mode=ft.CupertinoDatePickerMode.DATE,
expand=True,
)

sheet = ft.CupertinoBottomSheet(
height=260,
content=ft.Column(
spacing=0,
controls=[
ft.Row(
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
controls=[
ft.CupertinoButton(
content="Cancel",
on_click=lambda: page.pop_dialog(),
),
ft.CupertinoButton(content="Done", on_click=handle_done),
],
),
date_picker,
],
),
)

page.add(
ft.SafeArea(
content=ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
controls=[
selection := ft.Text("No date selected"),
ft.CupertinoFilledButton(
content="Choose a date",
on_click=lambda: page.show_dialog(sheet),
),
],
),
)
)


if __name__ == "__main__":
ft.run(main)

Action sheet in a bottom sheet​

Shows a CupertinoActionSheet with a title, a message, a default, a normal and a destructive action, and a Cancel button, in a CupertinoBottomSheet. Tapping an action closes the sheet and shows which one was tapped.

Sourceplay_arrowTry Online
import flet as ft


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

messages = ft.Column(tight=True)

def handle_click(e: ft.Event[ft.CupertinoActionSheetAction]):
messages.controls.append(ft.Text(f"Action clicked: {e.control.content.value}"))
messages.update()
page.pop_dialog()

action_sheet = ft.CupertinoActionSheet(
title=ft.Row(
alignment=ft.MainAxisAlignment.CENTER,
controls=[ft.Text("Title"), ft.Icon(ft.Icons.BEDTIME)],
),
message=ft.Row(
alignment=ft.MainAxisAlignment.CENTER,
controls=[ft.Text("Description"), ft.Icon(ft.Icons.AUTO_AWESOME)],
),
cancel=ft.CupertinoActionSheetAction(
on_click=handle_click,
content=ft.Text("Cancel"),
),
actions=[
ft.CupertinoActionSheetAction(
default=True,
on_click=handle_click,
content=ft.Text("Default Action"),
),
ft.CupertinoActionSheetAction(
on_click=handle_click,
content=ft.Text("Normal Action"),
),
ft.CupertinoActionSheetAction(
destructive=True,
on_click=handle_click,
content=ft.Text("Destructive Action"),
),
],
)

bottom_sheet = ft.CupertinoBottomSheet(action_sheet)

page.add(
ft.SafeArea(
content=ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
controls=[
ft.CupertinoFilledButton(
on_click=lambda: page.show_dialog(bottom_sheet),
content="Open CupertinoBottomSheet",
),
messages,
],
),
)
)


if __name__ == "__main__":
ft.run(main)

Properties​

bgcolorclass-attributeinstance-attribute​

bgcolor: ColorValue | None = None

The background color of the sheet.

Setting it places content on a sheet. If None and height or padding is set, CupertinoColors.SYSTEM_BACKGROUND is used.

contentinstance-attribute​

content: Control

The control to be displayed in this bottom sheet.

heightclass-attributeinstance-attribute​

height: Number | None = None

The height of the sheet.

Setting it places content on a sheet. If None, the sheet takes the height of content.

modalclass-attributeinstance-attribute​

modal: bool = False

Whether this bottom sheet stays open when the user taps outside of it.

openclass-attributeinstance-attribute​

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

paddingclass-attributeinstance-attribute​

padding: PaddingValue | None = None

The padding between the sheet's edges and content.

Setting it places content on a sheet.