BottomSheet#

Added in version 1.6.

class BottomSheet(**properties: Any)#

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Swipeable, Accessible, Buildable, ConstraintTarget

A bottom sheet with an optional bottom bar.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/bottom-sheet.png

AdwBottomSheet has three child widgets. content is shown persistently. sheet is displayed above it when it’s open, and bottom_bar is displayed when it’s not.

Bottom sheet and bottom bar are attached to the bottom edge of the widget. They take the full width by default, but can only take a portion of it if full_width is set to FALSE. In this case, align determines where along the bottom edge they are placed.

AdwBottomSheet can be useful for applications such as music players, that want to have a persistent bottom bar that expands into a bottom sheet when clicked. It’s meant for cases where a bottom sheet is tightly integrated into the UI. For more transient bottom sheets, see Dialog.

To open or close the bottom sheet, use the open property.

By default, the bottom sheet has an overlaid drag handle. It can be disabled by setting show_drag_handle to FALSE. Note that the handle also controls whether the sheet can be dragged using a pointer.

Bottom sheets are modal by default, meaning that the content is dimmed and cannot be accessed while the sheet is open. Set modal to FALSE if this behavior is unwanted.

To disable user interactions for opening or closing the bottom sheet (such as swipes or clicking the bottom bar or close button), set can_open or can_close to FALSE.

In some cases, particularly when using a full-width bottom bar, it may be necessary to shift content upwards. Use the bottom_bar_height and sheet_height for that.

AdwBottomSheet is not adaptive, and for larger window sizes applications may want to replace it with another UI, such as a sidebar. This can be done using MultiLayoutView.

Sizing#

Unlike Dialog presented as a bottom sheet, AdwBottomSheet just follows the content’s natural size, and it’s up to the applications to make sure their content provides one. For example, when using ScrolledWindow, make sure to set propagate_natural_height to TRUE.

Header Bar Integration#

When placed inside an AdwBottomSheet, HeaderBar will not show the title when show_drag_handle is TRUE, regardless of show_title. This only applies to the default title, titles set with title_widget will still be shown.


The AdwBottomSheet implementation of the Buildable interface supports setting the sheet widget by specifying “sheet” as the “type” attribute of a <child> element, and the bottom bar by specifying “bottom-bar”. Specifying “content” or omitting the child type results in setting the content child.

Constructors#

class BottomSheet
classmethod new() Widget#

Creates a new AdwBottomSheet.

Added in version 1.6.

Methods#

class BottomSheet
get_align() float#

Gets horizontal alignment of the bottom sheet.

Added in version 1.6.

get_bottom_bar() Widget | None#

Gets the bottom bar widget for self.

Added in version 1.6.

get_bottom_bar_height() int#

Gets the current bottom bar height.

It can be used to shift the content upwards permanently to accommodate for the bottom bar.

Added in version 1.6.

get_can_close() bool#

Gets whether the bottom sheet can be closed by user.

Added in version 1.6.

get_can_open() bool#

Gets whether the bottom sheet can be opened by user.

Added in version 1.6.

get_content() Widget | None#

Gets the content widget for self.

Added in version 1.6.

get_full_width() bool#

Gets whether the bottom sheet takes the full width.

Added in version 1.6.

get_modal() bool#

Gets whether the bottom sheet is modal.

Added in version 1.6.

get_open() bool#

Gets whether the bottom sheet is open.

Added in version 1.6.

get_sheet() Widget | None#

Gets the bottom sheet widget for self.

Added in version 1.6.

get_sheet_height() int#

Gets the current bottom sheet height.

It can be used to shift the content upwards when the bottom sheet is open.

Added in version 1.6.

get_show_drag_handle() bool#

Gets whether to show a drag handle in the bottom sheet.

Added in version 1.6.

set_align(align: float) None#

Sets horizontal alignment of the bottom sheet.

0 means the bottom sheet is flush with the start edge, 1 means it’s flush with the end edge. 0.5 means it’s centered.

Only used when full_width is set to FALSE.

Added in version 1.6.

Parameters:

align – the new alignment

set_bottom_bar(bottom_bar: Widget | None = None) None#

Sets the bottom bar widget for self.

Shown when open is FALSE. When open, morphs into the sheet.

Added in version 1.6.

Parameters:

bottom_bar – the bottom bar widget

set_can_close(can_close: bool) None#

Sets whether the bottom sheet can be closed by user.

It can be closed via the close button, swiping down, pressing Escape or clicking the content dimming (when modal).

Bottom sheet can still be closed using open.

Added in version 1.6.

Parameters:

can_close – whether the sheet can be closed by user

set_can_open(can_open: bool) None#

Sets whether the bottom sheet can be opened by user.

It can be opened via clicking or swiping up from the bottom bar.

Does nothing if bottom_bar is not set.

Bottom sheet can still be opened using open.

Added in version 1.6.

Parameters:

can_open – whether the sheet can be opened by user.

set_content(content: Widget | None = None) None#

Sets the content widget for self.

It’s always shown, and the bottom sheet is overlaid over it.

Added in version 1.6.

Parameters:

content – the content widget

set_full_width(full_width: bool) None#

Sets whether the bottom sheet takes the full width.

When full width, align is ignored.

Added in version 1.6.

Parameters:

full_width – whether the sheet takes up the full width

set_modal(modal: bool) None#

Sets whether the bottom sheet is modal.

When modal, content will be dimmed when the bottom sheet is open, and clicking it will close the bottom sheet. It also cannot be focused with keyboard.

Otherwise, the content is accessible even when the bottom sheet is open.

Added in version 1.6.

Parameters:

modal – whether the sheet is modal

set_open(open: bool) None#

Sets whether the bottom sheet is open.

Added in version 1.6.

Parameters:

open – whether to open the sheet

set_sheet(sheet: Widget | None = None) None#

Sets the bottom sheet widget for self.

Only shown when open is TRUE.

Added in version 1.6.

Parameters:

sheet – the sheet widget

set_show_drag_handle(show_drag_handle: bool) None#

Sets whether to show a drag handle in the bottom sheet.

The handle will be overlaid over sheet.

When the handle is shown, HeaderBar will hide its default title, and ToolbarView will reserve space if there are no top bars.

Showing drag handle also allows to swipe the bottom sheet down (and to swipe the bottom bar up) with a pointer, instead of just touchscreen.

Added in version 1.6.

Parameters:

show_drag_handle – whether to show the drag handle

Properties#

class BottomSheet
props.align: float#

The type of the None singleton.

Added in version 1.6.

props.bottom_bar: Widget#

The type of the None singleton.

Added in version 1.6.

props.bottom_bar_height: int#

The type of the None singleton.

Added in version 1.6.

props.can_close: bool#

The type of the None singleton.

Added in version 1.6.

props.can_open: bool#

The type of the None singleton.

Added in version 1.6.

props.content: Widget#

The type of the None singleton.

Added in version 1.6.

props.full_width: bool#

The type of the None singleton.

Added in version 1.6.

props.modal: bool#

The type of the None singleton.

Added in version 1.6.

props.open: bool#

The type of the None singleton.

Added in version 1.6.

props.sheet: Widget#

The type of the None singleton.

Added in version 1.6.

props.sheet_height: int#

The type of the None singleton.

Added in version 1.6.

props.show_drag_handle: bool#

The type of the None singleton.

Added in version 1.6.

Signals#

class BottomSheet.signals
close_attempt() None#

The type of the None singleton.

Added in version 1.6.