# Side Sheets [Side sheets](https://material.io/components/sheets-side) are surfaces containing supplementary content that are anchored to the side of the screen. See [Bottom Sheet documentation](BottomSheet.md) for documentation about [bottom sheets](https://m3.material.io/components/bottom-sheets/overview). **Contents** * [Design & API Documentation](#design-api-documentation) * [Using side sheets](#using-side-sheets) * [Standard side sheet](#standard-side-sheet) * [Modal side sheet](#modal-side-sheet) * [Coplanar side sheet](#coplanar-side-sheet) * [Anatomy and key properties](#anatomy-and-key-properties) * [Predictive Back](#predictive-back) * [Theming](#theming-side-sheets) ## Design & API Documentation * [Google Material3 Spec](https://material.io/components/side-sheets/overview) * [API Reference](https://developer.android.com/reference/com/google/android/material/sidesheet/package-summary) ## Using side sheets Before you can use Material side sheets, you need to add a dependency to the Material Components for Android library. For more information, go to the [Getting started](https://github.com/material-components/material-components-android/tree/master/docs/getting-started.md) page. Note: Side sheets were introduced in `1.8.0`. To use side sheets, make sure you're depending on [library version `1.8.0`](https://github.com/material-components/material-components-android/releases/tag/1.8.0) or later. Standard side sheet basic usage: ```xml ``` ### Setting behavior There are several attributes that can be used to adjust the behavior of standard and modal side sheets. Behavior attributes can be applied to standard side sheets in xml by setting them on a child `View` set to `app:layout_behavior`, or programmatically: ```kt val standardSideSheetBehavior = SideSheetBehavior.from(standardSideSheet) // Use this to programmatically apply behavior attributes ``` More information about these attributes and their default values is available in the [behavior attributes](#behavior-attributes) section. ### Setting state Standard side sheets have the following states: * `STATE_EXPANDED`: The side sheet is visible at its maximum height and it is neither dragging nor settling (see below). * `STATE_HIDDEN`: The side sheet is no longer visible and can only be re-shown programmatically. * `STATE_DRAGGING`: The user is actively dragging the side sheet. * `STATE_SETTLING`: The side sheet is settling to a specific height after a drag/swipe gesture. This will be the peek height, expanded height, or 0, in case the user action caused the side sheet to hide. You can set a state on the side sheet: ```kt sideSheetBehavior.state = Sheet.STATE_HIDDEN ``` **Note:** `STATE_SETTLING` and `STATE_DRAGGING` should not be set programmatically. ### Listening to state and slide changes `SideSheetCallback`s can be added to a `SideSheetBehavior` to listen for state and slide changes: ```kt val sideSheetCallback = object : SideSheetBehavior.SideSheetCallback() { override fun onStateChanged(sideSheet: View, newState: Int) { // Do something for new state. } override fun onSlide(sideSheet: View, slideOffset: Float) { // Do something for slide offset. } } // To add a callback: sideSheetBehavior.addCallback(sideSheetCallback) // To remove a callback: sideSheetBehavior.removeCallback(sideSheetCallback) ``` ## Standard side sheet Standard side sheets co-exist with the screen’s main UI region and allow for simultaneously viewing and interacting with both regions. They are commonly used to keep a feature or secondary content visible on screen when content in the main UI region is frequently scrolled or panned. `SideSheetBehavior` is applied to a child of [CoordinatorLayout](https://developer.android.com/reference/androidx/coordinatorlayout/widget/CoordinatorLayout) to make that child a **standard side sheet**, which is a view that comes up from the side of the screen, elevated over the main content. It can be dragged vertically to expose more or less content. API and source code: * `SideSheetBehavior` * [Class definition](https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior) * [Class source](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/sidesheet/SideSheetBehavior.java) ### Standard side sheet example `SideSheetBehavior` works in tandem with `CoordinatorLayout` to let you display content in a side sheet, perform enter/exit animations, respond to dragging/swiping gestures, and more. Apply the `SideSheetBehavior` to a direct child `View` of `CoordinatorLayout`: ```xml