title: Jetpack Compose collapse Bottom Sheet on outside click
body: <p>I currently display a Bottom Sheet through a <code>BottomSheetScaffold</code> and want to collapse it when the user clicks outside the Bottom Sheet. Is there a way to detect the click outside of the Bottom Sheet?</p>
  <p>This is the screen with my <code>BottomSheetScaffold</code>:</p>
  <pre><code>@ExperimentalMaterialApi
  @ExperimentalMaterial3Api
  @Composable
  fun HomeScreen() {
      val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
          bottomSheetState = BottomSheetState(BottomSheetValue.Collapsed)
      )
      val coroutineScope = rememberCoroutineScope()
  
      BottomSheetScaffold(
          scaffoldState = bottomSheetScaffoldState,
          sheetContent = {
              Box(
                  Modifier
                      .fillMaxWidth()
                      .fillMaxHeight(0.9f)
              ) {
                  Text(&quot;Hello from Sheet&quot;)
              }
          },
          sheetShape = RoundedCornerShape(
              topStart = Spacing.l,
              topEnd = Spacing.l
          ),
          sheetPeekHeight = LocalConfiguration.current.screenHeightDp.dp * 0.15f,
          sheetBackgroundColor = MaterialTheme.colorScheme.surface,
      ) {
          Scaffold() {
              Button(
                  onClick = {
                      coroutineScope.launch {
                          if (bottomSheetScaffoldState.bottomSheetState.isCollapsed) {
                              bottomSheetScaffoldState.bottomSheetState.expand()
                          } else {
                              bottomSheetScaffoldState.bottomSheetState.collapse()
                          }
                      }
                  },
              ) {
                  Text(&quot;Toggle Sheet&quot;)
              }
          }
  
      }
  }
  </code></pre>
  <p>This is a visualization of the area in which I want to detect the click if the Bottom Sheet is expanded.</p>
  <p><a href="https://i.stack.imgur.com/PN0rt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PN0rt.png" alt="enter image description here" /></a></p>