:right-sidebar: True BottomSheet =================================================================== .. currentmodule:: gi.repository.Adw .. versionadded:: 1.6 .. class:: BottomSheet(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Adw.Swipeable`, :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` A bottom sheet with an optional bottom bar. .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/bottom-sheet.png ``AdwBottomSheet`` has three child widgets. :obj:`~gi.repository.Adw.BottomSheet.props.content` is shown persistently. :obj:`~gi.repository.Adw.BottomSheet.props.sheet` is displayed above it when it's open, and :obj:`~gi.repository.Adw.BottomSheet.props.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 :obj:`~gi.repository.Adw.BottomSheet.props.full_width` is set to ``FALSE``\. In this case, :obj:`~gi.repository.Adw.BottomSheet.props.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 :obj:`~gi.repository.Adw.Dialog`\. To open or close the bottom sheet, use the :obj:`~gi.repository.Adw.BottomSheet.props.open` property. By default, the bottom sheet has an overlaid drag handle. It can be disabled by setting :obj:`~gi.repository.Adw.BottomSheet.props.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 :obj:`~gi.repository.Adw.BottomSheet.props.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 :obj:`~gi.repository.Adw.BottomSheet.props.can_open` or :obj:`~gi.repository.Adw.BottomSheet.props.can_close` to ``FALSE``\. In some cases, particularly when using a full-width bottom bar, it may be necessary to shift :obj:`~gi.repository.Adw.BottomSheet.props.content` upwards. Use the :obj:`~gi.repository.Adw.BottomSheet.props.bottom_bar_height` and :obj:`~gi.repository.Adw.BottomSheet.props.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 :obj:`~gi.repository.Adw.MultiLayoutView`\. Sizing -------------------------------------------------------------------------------- Unlike :obj:`~gi.repository.Adw.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 :obj:`~gi.repository.Gtk.ScrolledWindow`\, make sure to set :obj:`~gi.repository.Gtk.ScrolledWindow.props.propagate_natural_height` to ``TRUE``\. Header Bar Integration -------------------------------------------------------------------------------- When placed inside an ``AdwBottomSheet``\, :obj:`~gi.repository.Adw.HeaderBar` will not show the title when :obj:`~gi.repository.Adw.BottomSheet.props.show_drag_handle` is ``TRUE``\, regardless of :obj:`~gi.repository.Adw.HeaderBar.props.show_title`\. This only applies to the default title, titles set with :obj:`~gi.repository.Adw.HeaderBar.props.title_widget` will still be shown. -------------------------------------------------------------------------------- The ``AdwBottomSheet`` implementation of the :obj:`~gi.repository.Gtk.Buildable` interface supports setting the sheet widget by specifying “sheet” as the “type” attribute of a ```` element, and the bottom bar by specifying “bottom-bar”. Specifying “content” or omitting the child type results in setting the content child. Constructors ------------ .. rst-class:: interim-class .. class:: BottomSheet :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a new ``AdwBottomSheet``\. .. versionadded:: 1.6 Methods ------- .. rst-class:: interim-class .. class:: BottomSheet :no-index: .. method:: get_align() -> float Gets horizontal alignment of the bottom sheet. .. versionadded:: 1.6 .. method:: get_bottom_bar() -> ~gi.repository.Gtk.Widget | None Gets the bottom bar widget for ``self``\. .. versionadded:: 1.6 .. method:: 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. .. versionadded:: 1.6 .. method:: get_can_close() -> bool Gets whether the bottom sheet can be closed by user. .. versionadded:: 1.6 .. method:: get_can_open() -> bool Gets whether the bottom sheet can be opened by user. .. versionadded:: 1.6 .. method:: get_content() -> ~gi.repository.Gtk.Widget | None Gets the content widget for ``self``\. .. versionadded:: 1.6 .. method:: get_full_width() -> bool Gets whether the bottom sheet takes the full width. .. versionadded:: 1.6 .. method:: get_modal() -> bool Gets whether the bottom sheet is modal. .. versionadded:: 1.6 .. method:: get_open() -> bool Gets whether the bottom sheet is open. .. versionadded:: 1.6 .. method:: get_sheet() -> ~gi.repository.Gtk.Widget | None Gets the bottom sheet widget for ``self``\. .. versionadded:: 1.6 .. method:: 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. .. versionadded:: 1.6 .. method:: get_show_drag_handle() -> bool Gets whether to show a drag handle in the bottom sheet. .. versionadded:: 1.6 .. method:: 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 :obj:`~gi.repository.Adw.BottomSheet.props.full_width` is set to ``FALSE``\. .. versionadded:: 1.6 :param align: the new alignment .. method:: set_bottom_bar(bottom_bar: ~gi.repository.Gtk.Widget | None = None) -> None Sets the bottom bar widget for ``self``\. Shown when :obj:`~gi.repository.Adw.BottomSheet.props.open` is ``FALSE``\. When open, morphs into the :obj:`~gi.repository.Adw.BottomSheet.props.sheet`\. .. versionadded:: 1.6 :param bottom_bar: the bottom bar widget .. method:: 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 :kbd:`Escape` or clicking the content dimming (when modal). Bottom sheet can still be closed using :obj:`~gi.repository.Adw.BottomSheet.props.open`\. .. versionadded:: 1.6 :param can_close: whether the sheet can be closed by user .. method:: 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 :obj:`~gi.repository.Adw.BottomSheet.props.bottom_bar` is not set. Bottom sheet can still be opened using :obj:`~gi.repository.Adw.BottomSheet.props.open`\. .. versionadded:: 1.6 :param can_open: whether the sheet can be opened by user. .. method:: set_content(content: ~gi.repository.Gtk.Widget | None = None) -> None Sets the content widget for ``self``\. It's always shown, and the bottom sheet is overlaid over it. .. versionadded:: 1.6 :param content: the content widget .. method:: set_full_width(full_width: bool) -> None Sets whether the bottom sheet takes the full width. When full width, :obj:`~gi.repository.Adw.BottomSheet.props.align` is ignored. .. versionadded:: 1.6 :param full_width: whether the sheet takes up the full width .. method:: set_modal(modal: bool) -> None Sets whether the bottom sheet is modal. When modal, :obj:`~gi.repository.Adw.BottomSheet.props.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. .. versionadded:: 1.6 :param modal: whether the sheet is modal .. method:: set_open(open: bool) -> None Sets whether the bottom sheet is open. .. versionadded:: 1.6 :param open: whether to open the sheet .. method:: set_sheet(sheet: ~gi.repository.Gtk.Widget | None = None) -> None Sets the bottom sheet widget for ``self``\. Only shown when :obj:`~gi.repository.Adw.BottomSheet.props.open` is ``TRUE``\. .. versionadded:: 1.6 :param sheet: the sheet widget .. method:: 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 :obj:`~gi.repository.Adw.BottomSheet.props.sheet`\. When the handle is shown, :obj:`~gi.repository.Adw.HeaderBar` will hide its default title, and :obj:`~gi.repository.Adw.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. .. versionadded:: 1.6 :param show_drag_handle: whether to show the drag handle Properties ---------- .. rst-class:: interim-class .. class:: BottomSheet :no-index: .. attribute:: props.align :type: float The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.bottom_bar :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.bottom_bar_height :type: int The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.can_close :type: bool The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.can_open :type: bool The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.content :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.full_width :type: bool The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.modal :type: bool The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.open :type: bool The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.sheet :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.sheet_height :type: int The type of the None singleton. .. versionadded:: 1.6 .. attribute:: props.show_drag_handle :type: bool The type of the None singleton. .. versionadded:: 1.6 Signals ------- .. rst-class:: interim-class .. class:: BottomSheet.signals :no-index: .. method:: close_attempt() -> None The type of the None singleton. .. versionadded:: 1.6