---
title: "Drawer"
description: "A draggable bottom panel with compact content, floating surfaces and scroll-to-expand pages."
---

# Drawer

A draggable bottom panel with compact content, floating surfaces and scroll-to-expand pages.

## Installation

Install the shared package once in your Exact app. This version is a beta.

```sh
bun add --exact @rightui/ui@0.4.0-beta.4
```

Or choose another package manager:

```sh
npm install --save-exact @rightui/ui@0.4.0-beta.4
pnpm add --save-exact @rightui/ui@0.4.0-beta.4
yarn add --exact @rightui/ui@0.4.0-beta.4
```

Exact compilation uses Bun 1.4.2. Register Geist and Newsreader, declare the font marker and add the root provider using [Installation](/docs/installation).

### Manual source setup

Install an editable copy of the complete package:

```sh
mkdir -p vendor/rightui vendor/rightui-ui
npm pack @rightui/ui@0.4.0-beta.4 --pack-destination vendor/rightui
tar -xzf ./vendor/rightui/rightui-ui-0.4.0-beta.4.tgz -C vendor/rightui-ui --strip-components=1
bun add file:./vendor/rightui-ui
```

Keep package.json, the Contract files, ui.tamber, assets and licenses together.

### Import

```contract
use Drawer, DrawerAdvanced, DrawerContent, DrawerOptions, DrawerBody, DrawerInset, DrawerFooter from "@rightui/ui"
```

## Usage

Use Drawer or DrawerAdvanced for an internally managed bottom panel. DrawerContent adds a controlled snapPoint/changeSnap pair and DrawerOptions for detached surfaces, optional controls, backdrop opacity, bounce and scroll behavior. Compose fixed content with DrawerInset and DrawerFooter around a DrawerBody. Each scroll body has its own compact inset; avoid duplicating it. Scroll-to-expand animates to full available height while preserving the same controls. See docs/DRAWER.md for all required props and the scroll/resize boundary.

## Example

```contract
use FontWeights from "@rightui/ui"
use uiFontFamily, Dialog, Button, Drawer, DrawerAdvanced, DrawerContent, DrawerOptions, DrawerBody, DrawerInset, DrawerFooter from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiWeights: FontWeights
    uiFont: string
  derive narrow = width < 600
  state drawerShown = false
  state responsiveShown = false
  state floatingShown = false
  state floatingSnap = 0.45
  state floatingBackdrop = 0.35
  state handlelessShown = false
  state handlelessSnap = 0.45
  state pageShown = false
  state pageSnap = 0.45
  derive floatingOptions = DrawerOptions(detached=true, showHandle=true, showCloseButton=true, backdropOpacity=floatingBackdrop, dismissOnBackdrop=true, bounce=true, scrollable=true, expandOnScroll=false)
  derive handlelessOptions = DrawerOptions(detached=false, showHandle=false, showCloseButton=true, backdropOpacity=0.6, dismissOnBackdrop=true, bounce=false, scrollable=true, expandOnScroll=false)
  derive pageOptions = DrawerOptions(detached=false, showHandle=true, showCloseButton=true, backdropOpacity=0.5, dismissOnBackdrop=true, bounce=true, scrollable=false, expandOnScroll=false)
  action openFloating
    floatingSnap = 0.45
    floatingShown = true
  action closeFloating
    floatingShown = false
    focus("drawer-floating-open")
  action changeFloatingSnap(value: number)
    floatingSnap = value
  action changeFloatingBackdrop(value: number)
    floatingBackdrop = value
  action openHandleless
    handlelessSnap = 0.45
    handlelessShown = true
  action closeHandleless
    handlelessShown = false
    focus("drawer-handleless-open")
  action changeHandlelessSnap(value: number)
    handlelessSnap = value
  action openPage
    pageSnap = 0.45
    pageShown = true
  action closePage
    pageShown = false
    focus("drawer-page-open")
  action changePageSnap(value: number)
    pageSnap = value
  action expandPage
    pageSnap = 1
  action openResponsive
    responsiveShown = true
  action closeResponsive
    responsiveShown = false
    focus("drawer-responsive-open")
  state activityGoal = 350
  derive reduce = reduced
  action hideDrawer
    drawerShown = false
    focus("drawer-open")
  action adjustGoal(delta: number)
    activityGoal = max(200, min(500, activityGoal + delta))
  action openExample
    drawerShown = true
  view
    column gap="ui.space-16" min-width=0 max-width="100%"
      Button(id="drawer-open", label="Open drawer", variant="outline", disabled=false, press=openExample)
      DrawerAdvanced(snapPoints=[0.3, 0.9], initialSnap=0.3, id="controls-drawer", open=drawerShown, title="Move Goal", description="Drag the handle to 30% or 90%. Pull down to close.", reduced=reduce, focusIds=["controls-goal-less", "controls-goal-more", "controls-drawer-submit"], dismiss=hideDrawer)
        column gap="ui.space-16" align-items="center"
          row gap="ui.space-24" align-items="center" justify-content="center"
            Button(id="controls-goal-less", label="−", variant="outline", disabled=(activityGoal == 200), press=adjustGoal(-10))
            column align-items="center"
              text activityGoal.toString() testId="controls-goal" font-size="ui.text-6xl" font-weight=uiWeights.bold font-family=uiFontFamily(uiFont) data-rightui-font="body"
              text "CALORIES/DAY" font-size="ui.text-xs" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
            Button(id="controls-goal-more", label="+", variant="outline", disabled=(activityGoal == 500), press=adjustGoal(10))
          row gap="ui.space-6" align-items="flex-end" height="ui.space-80" aria-hidden=true
            for height, i in [30, 50, 40, 65, 45, 70, 55, 80, 62, 48] key=i
              view width="ui.space-20" height=height border-radius="ui.radius-xs" background-color="ui.primary"
          Button(id="controls-drawer-submit", label="Submit", variant="primary", disabled=false, press=hideDrawer)
        column id="drawer-long-content" max-height=180 overflow="auto" gap="ui.space-12"
          for section in ["Overview", "Preferences", "Permissions", "Storage", "Notifications", "Accessibility", "Review"] key=section
            text (section + ": review the project settings before continuing.") font-family=uiFontFamily(uiFont) data-rightui-font="body"
      text "Floating drawer" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Button(id="drawer-floating-open", label="Open floating drawer", variant="outline", disabled=false, press=openFloating)
      DrawerContent(id="drawer-floating", open=floatingShown, title="A little breathing room", description="Detached edges, rounded corners and a backdrop you can adjust.", reduced=reduced, focusIds=["drawer-backdrop-light", "drawer-backdrop-medium", "drawer-backdrop-strong", "drawer-floating-done"], dismiss=closeFloating, snapPoints=[0.45, 0.9], snapPoint=floatingSnap, changeSnap=changeFloatingSnap, options=floatingOptions)
        text "Backdrop intensity" font-weight=uiWeights.medium font-family=uiFontFamily(uiFont) data-rightui-font="body"
        row gap="ui.space-8" flex-wrap="wrap"
          Button(id="drawer-backdrop-light", label="Light", variant=(floatingBackdrop == 0.2 ? "primary" : "outline"), disabled=false, press=changeFloatingBackdrop(0.2))
          Button(id="drawer-backdrop-medium", label="Medium", variant=(floatingBackdrop == 0.35 ? "primary" : "outline"), disabled=false, press=changeFloatingBackdrop(0.35))
          Button(id="drawer-backdrop-strong", label="Strong", variant=(floatingBackdrop == 0.7 ? "primary" : "outline"), disabled=false, press=changeFloatingBackdrop(0.7))
        text "Drag the handle and release to feel the spring settle." font-size="ui.text-sm" line-height="ui.leading-normal" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        Button(id="drawer-floating-done", label="Done", variant="primary", disabled=false, press=closeFloating)
      text "No handle" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Button(id="drawer-handleless-open", label="Open without a handle", variant="outline", disabled=false, press=openHandleless)
      DrawerContent(id="drawer-handleless", open=handlelessShown, title="A focused panel", description="The handle is optional. Close controls remain available.", reduced=reduced, focusIds=["drawer-handleless-done"], dismiss=closeHandleless, snapPoints=[0.45, 0.9], snapPoint=handlelessSnap, changeSnap=changeHandlelessSnap, options=handlelessOptions)
        text "Use this variation when the content should stay at one comfortable height. This example also disables the settling bounce." font-size="ui.text-sm" line-height="ui.leading-normal" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        Button(id="drawer-handleless-done", label="Done", variant="primary", disabled=false, press=closeHandleless)
      text "Scroll to full screen" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Button(id="drawer-page-open", label="Open expandable page", variant="outline", disabled=false, press=openPage)
      DrawerContent(id="drawer-page", open=pageShown, title="Project overview", description="Scroll the details to expand. The summary and footer stay in place.", reduced=reduced, focusIds=["drawer-page-done"], dismiss=closePage, snapPoints=[0.45, 0.9, 1], snapPoint=pageSnap, changeSnap=changePageSnap, options=pageOptions)
        column id="drawer-page-summary" testId="drawer-page-summary" flex-shrink=0 border-bottom-width="ui.border-width" border-bottom-style="solid" border-bottom-color="ui.border"
          DrawerInset(compact=false)
            text "RIGHTUI / PROJECT DETAILS" font-size="ui.text-xs" font-weight=uiWeights.medium color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        DrawerBody(compact=false, id="drawer-page-body", expanded=(pageSnap >= 1), expandOnScroll=true, expand=expandPage)
          for section in ["Overview", "Workspace", "Appearance", "Typography", "Components", "Interactions", "Accessibility", "Notifications", "Storage", "Privacy", "Export", "Review"] key=section
            column gap="ui.space-6" padding="ui.space-12 0px" border-bottom-width="ui.border-width" border-bottom-style="solid" border-bottom-color="ui.border"
              text section font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
              text "Review these settings without leaving the current page. Only this central area scrolls; the summary above and the action below stay visible." font-size="ui.text-sm" line-height="ui.leading-normal" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        DrawerFooter(compact=false)
          Button(id="drawer-page-done", label="Done", variant="primary", disabled=false, press=closePage)
      text "Responsive dialog" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Button(id="drawer-responsive-open", label="Open responsive dialog", variant="outline", disabled=false, press=openResponsive)
      if narrow
        Drawer(id="drawer-responsive-small", open=responsiveShown, title="Responsive drawer", description="A drawer on narrow screens, a dialog on wide screens.", reduced=reduced, focusIds=["drawer-responsive-save"], dismiss=closeResponsive)
          Button(id="drawer-responsive-save", label="Save", variant="primary", disabled=false, press=closeResponsive)
      else
        Dialog(id="drawer-responsive-dialog", open=responsiveShown, reduced=reduced, title="Responsive dialog", description="A dialog on wide screens, a drawer on narrow screens.", confirmLabel="Save", focusIds=["drawer-responsive-dialog-cancel", "drawer-responsive-dialog-confirm"], dismiss=closeResponsive, confirm=closeResponsive)
          text "Resize the viewport to try each presentation." font-family=uiFontFamily(uiFont) data-rightui-font="body"

```

## Keyboard

On the resize handle: ArrowUp/ArrowDown select the next/previous stop, Home/End select the smallest/largest stop, and Enter/Space cycle stops. Escape dismisses. Tab/Shift+Tab remain within the handle, close button and supplied focusIds.

## API Reference

| Property | Type |
| --- | --- |
| Drawer.id | string |
| Drawer.open | bool |
| Drawer.title | string |
| Drawer.description | string |
| Drawer.reduced | bool |
| Drawer.focusIds | string[] |
| Drawer.dismiss | action |
| DrawerAdvanced.id | string |
| DrawerAdvanced.open | bool |
| DrawerAdvanced.title | string |
| DrawerAdvanced.description | string |
| DrawerAdvanced.reduced | bool |
| DrawerAdvanced.focusIds | string[] |
| DrawerAdvanced.dismiss | action |
| DrawerAdvanced.snapPoints | number[] |
| DrawerAdvanced.initialSnap | number |
| DrawerContent.id | string |
| DrawerContent.open | bool |
| DrawerContent.title | string |
| DrawerContent.description | string |
| DrawerContent.reduced | bool |
| DrawerContent.focusIds | string[] |
| DrawerContent.dismiss | action |
| DrawerContent.snapPoints | number[] |
| DrawerContent.snapPoint | number |
| DrawerContent.changeSnap | action |
| DrawerContent.options | DrawerOptions |
| DrawerBody.compact | bool |
| DrawerBody.id | string |
| DrawerBody.expanded | bool |
| DrawerBody.expandOnScroll | bool |
| DrawerBody.expand | action |
| DrawerInset.compact | bool |
| DrawerFooter.compact | bool |

## Web overlay setup

Load the packaged assets/sheet.css in the web head for viewport positioning and modal scroll locking. Native hosts use the same RightUI surfaces directly. Keep open state in the parent and restore focus in dismiss; list interactive children in focusIds.

```json
{
  "data": ["rightui-font", "rightui-sheet"],
  "host": {
    "web": {
      "head": [{ "link": { "rel": "stylesheet", "href": "/assets/sheet.css" } }]
    }
  }
}
```

## Source

File: packages/ui/drawer.contract

```contract
use FontWeights from "./typography-context.contract"
use OverlayLayer from "./overlay-layer.contract"
use uiFontFamily from "./typography-context.contract"

style DrawerDetached
  padding-top="env(safe-area-inset-top, 0px)"
  padding-bottom="env(safe-area-inset-bottom, 0px)"
  padding-left="env(safe-area-inset-left, 0px)"
  padding-right="env(safe-area-inset-right, 0px)"

style DrawerFloatingGap
  padding="ui.drawer-floating-gap"

style DrawerAttached
  padding="0px"

shape DrawerOptions
  detached: bool
  showHandle: bool
  showCloseButton: bool
  backdropOpacity: number
  dismissOnBackdrop: bool
  bounce: bool
  scrollable: bool
  expandOnScroll: bool

fn drawerStops(points: number[]): number[] = points.filter(p => p > 0 and p <= 1).length == 0 ? [0.3, 0.9] : sortBy(points.filter((p, i) => p > 0 and p <= 1 and points.indexOf(p) == i), p => p)
fn drawerClosest(points: number[], value: number): number = match sortBy(points, p => max(p - value, value - p)).at(0) { case some(p) => p, case none => 0.3 }

component Drawer
  props
    id: string
    open: bool
    title: string
    description: string
    reduced: bool
    focusIds: string[]
    dismiss: action
  slot
  view
    DrawerAdvanced(id=id, open=open, title=title, description=description, reduced=reduced, focusIds=focusIds, dismiss=dismiss, snapPoints=[0.3, 0.9], initialSnap=0.3)
      children

component DrawerAdvanced
  props
    id: string
    open: bool
    title: string
    description: string
    reduced: bool
    focusIds: string[]
    dismiss: action
    snapPoints: number[]
    initialSnap: number
  slot
  view
    if open
      DrawerSession(id=id, title=title, description=description, reduced=reduced, focusIds=focusIds, dismiss=dismiss, snapPoints=drawerStops(snapPoints), initialSnap=initialSnap, panelId=id, showCloseButton=true, safeBottom=true, scrollable=true)
        children

// Compatibility wrapper: each mount starts at the requested initial stop.
component DrawerSession
  props
    id: string
    panelId: string
    showCloseButton: bool
    safeBottom: bool
    scrollable: bool
    title: string
    description: string
    reduced: bool
    focusIds: string[]
    dismiss: action
    snapPoints: number[]
    initialSnap: number
  slot
  state selected = drawerClosest(snapPoints, initialSnap)
  action choose(value: number)
    selected = value
  view
    DrawerSurface(id=id, panelId=panelId, safeBottom=safeBottom, title=title, description=description, reduced=reduced, focusIds=focusIds, dismiss=dismiss, snapPoints=snapPoints, snapPoint=selected, changeSnap=choose, options=DrawerOptions(detached=false, showHandle=true, showCloseButton=showCloseButton, backdropOpacity=0.5, dismissOnBackdrop=true, bounce=true, scrollable=scrollable, expandOnScroll=false))
      children

// A controlled, composable surface; slot actions deliberately stay with their caller.
component DrawerContent
  props
    id: string
    open: bool
    title: string
    description: string
    reduced: bool
    focusIds: string[]
    dismiss: action
    snapPoints: number[]
    snapPoint: number
    changeSnap: action
    options: DrawerOptions
  slot
  view
    if open
      DrawerSurface(id=id, panelId=id, safeBottom=true, title=title, description=description, reduced=reduced, focusIds=focusIds, dismiss=dismiss, snapPoints=drawerStops(options.expandOnScroll ? snapPoints.concat([1]) : snapPoints), snapPoint=snapPoint, changeSnap=changeSnap, options=options)
        children

component DrawerSurface
  props
    id: string
    panelId: string
    safeBottom: bool
    title: string
    description: string
    reduced: bool
    focusIds: string[]
    dismiss: action
    snapPoints: number[]
    snapPoint: number
    changeSnap: action
    options: DrawerOptions
  inject
    uiWeights: FontWeights
    uiFont: string
  slot
  state fullHeight = 0
  state displayedHeight = 0
  state panelTop = 0
  state safeTop = 0
  state panelRadius = 0
  state closing = false
  state focused = ""
  derive selected = drawerClosest(snapPoints, snapPoint)
  derive heightPx = closing ? 0 : fullHeight * selected
  derive maximum = match snapPoints.at(snapPoints.length - 1) { case some(p) => p, case none => 0.9 }
  derive minimum = match snapPoints.at(0) { case some(p) => p, case none => 0.3 }
  derive expanded = selected >= 0.999
  derive targets = (options.showHandle ? [id + "-handle"] : []).concat(options.showCloseButton ? [id + "-close"] : []).concat(focusIds)
  derive headerInset = options.detached ? 0 : max(0, safeTop - max(0, panelTop))
  derive corner = panelRadius * min(1, max(0, (fullHeight - displayedHeight) / max(1, safeTop + panelRadius * 2)))
  derive initialTarget = options.showHandle ? id + "-handle" : options.showCloseButton ? id + "-close" : panelId
  action measureMetrics(width: number, height: number)
    panelRadius = width
    safeTop = height
  action measureViewport(width: number, height: number)
    if height > 0
      fullHeight = height
  action measurePanel(width: number, height: number)
    let bounds = frame(panelId)
    let next = bounds.unavailable ? height : bounds.height
    if not bounds.unavailable
      panelTop = bounds.y
    if next != displayedHeight
      displayedHeight = next
    if closing and height <= 0.5
      dismiss()
  action choose(value: number)
    closing = false
    changeSnap(value)
  action snap(height: number, velocity: number)
    if fullHeight > 0
      let next = drawerClosest([0].concat(snapPoints), (height + velocity * 0.15) / fullHeight)
      if next == 0
        requestClose()
      else
        choose(next)
  action requestClose
    if reduced or displayedHeight <= 2.5
      dismiss()
    else
      closing = true
  action backdropPress
    if options.dismissOnBackdrop
      requestClose()
  action expandPage
    if options.expandOnScroll and not expanded
      choose(1)
  action cycle
    match snapPoints.filter(p => p > selected).at(0)
      case some(next)
        choose(next)
      case none
        choose(minimum)
  action handleKeys(k: string)
    if k == "ArrowUp" or k == "ArrowDown" or k == "Home" or k == "End" or k == "Enter" or k == " "
      preventDefault()
      stopPropagation()
      if k == "Home"
        choose(minimum)
      else if k == "End"
        choose(maximum)
      else if k == "ArrowUp"
        match snapPoints.filter(p => p > selected).at(0)
          case some(next)
            choose(next)
          case none
            choose(maximum)
      else if k == "ArrowDown"
        match sortBy(snapPoints.filter(p => p < selected), p => p, "desc").at(0)
          case some(next)
            choose(next)
          case none
            choose(minimum)
      else
        cycle()
  action remember(e: FocusEvent)
    focused = e.target
  action keys(k: string, e: KeyboardEvent)
    if not e.isComposing
      if k == "Escape"
        preventDefault()
        stopPropagation()
        requestClose()
      else if k == "Tab"
        preventDefault()
        stopPropagation()
        let index = targets.indexOf(focused)
        let next = index < 0 ? (e.shiftKey ? targets.length - 1 : 0) : (index + (e.shiftKey ? targets.length - 1 : 1)) % max(1, targets.length)
        match targets.at(next)
          case some(target)
            focus(target)
          case none
            focus(panelId)
  action blockScroll(e: WheelEvent)
    if not e.ctrlKey
      preventDefault()
  view
    OverlayLayer(id=id, modal=true, initialFocus=initialTarget, reduced=reduced)
      column class=(options.detached ? DrawerDetached : DrawerAttached) position="absolute" inset=0 pointer-events="none" justify-content="flex-end" box-sizing="border-box"
        view position="absolute" width="ui.radius-panel" height="env(safe-area-inset-top, 0px)" opacity=0 pointer-events="none" aria-hidden=true resize=measureMetrics
        view id=(id + "-backdrop") testId=(id + "-backdrop") position="absolute" inset=0 background-color="ui.drawer-backdrop" opacity=(min(1, max(0, options.backdropOpacity)) * min(1, max(0, displayedHeight / max(1, fullHeight * maximum)))) pointer-events="auto" aria-hidden=true press=backdropPress wheel=blockScroll touch-action="none"
        column class=(options.detached ? DrawerFloatingGap : DrawerAttached) width="100%" height="100%" min-height="0px" box-sizing="border-box" pointer-events="none" justify-content="flex-end" resize=measureViewport
          column id=panelId testId=id resize=measurePanel role="dialog" tabindex=-1 aria-modal=true aria-labelledby=(id + "-title") aria-describedby=(id + "-description") keycapture=keys focusin=remember
            position="relative" pointer-events="auto" width="100%" height=heightPx max-height=fullHeight min-height="0px" flex-shrink=0 box-sizing="border-box" overflow="clip" background-color="ui.surface" color="ui.foreground" outline="none" border-width=(options.detached ? "ui.border-width" : "0px") border-style="solid" border-color="ui.border" border-top-width="ui.border-width" border-top-left-radius=corner border-top-right-radius=corner border-bottom-left-radius=(options.detached ? corner : 0) border-bottom-right-radius=(options.detached ? corner : 0) box-shadow=(options.detached ? "ui.shadow-preview" : "ui.shadow-panel")
            transition=(reduced ? "none" : options.bounce ? "height ui.easing-drawer-bounce" : "height ui.easing-drawer")
            column padding-top=headerInset position="relative" flex-shrink=0 min-width="0px" heightDragFor=panelId heightrelease=snap touch-action="none"
              if options.showHandle
                view id=(id + "-handle") testId=(id + "-handle") tabindex=0 role="slider" aria-label="Resize drawer" aria-orientation="vertical" aria-valuemin=0 aria-valuemax=(maximum * 100) aria-valuenow=(selected * 100) aria-valuetext=(selected * 100).toFixed(0) + "% of available height" heightDragFor=panelId heightrelease=snap press=cycle key=handleKeys align-self="center" width="ui.drawer-handle-target-width" height="ui.drawer-handle-target-height" min-height="ui.drawer-handle-target-height" flex-shrink=0 display="flex" justify-content="center" align-items="center" touch-action="none" cursor="ns-resize"
                  -exact-hit-slop="ui.space-12 ui.space-16"
                  :focus-visible
                    box-shadow="ui.shadow-focus"
                  view width="ui.drawer-handle-width" height="ui.drawer-handle-height" border-radius="ui.radius-full" background-color="ui.muted-foreground" opacity=0.4 pointer-events="none"
              else
                view height="ui.space-12" flex-shrink=0
              column gap="ui.space-6" padding="ui.space-8 ui.space-48 ui.space-8" text-align="center"
                text title id=(id + "-title") role="heading" aria-level=2 font-size="ui.text-lg" font-weight=uiWeights.semibold color="ui.foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
                text description id=(id + "-description") font-size="ui.text-sm" line-height="ui.leading-normal" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
              if options.showCloseButton
                button id=(id + "-close") testId=(id + "-close") top=headerInset margin-top="ui.space-8" appearance="none" press=requestClose aria-label="Close drawer" position="absolute" right="ui.space-8" width="ui.space-44" height="ui.space-44" display="flex" justify-content="center" align-items="center" border="none" border-radius="ui.radius-control" background-color="transparent" color="ui.foreground"
                  svg width="ui.space-16" height="ui.space-16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="ui.stroke-standard" aria-hidden=true
                    path d="m6 6 12 12M6 18 18 6"
            column min-width="0px" min-height="0px" flex="1 1 auto" padding-bottom=(safeBottom and not options.detached and not options.scrollable ? "env(safe-area-inset-bottom, 0px)" : "0px")
              if options.scrollable
                DrawerBodySurface(id=id + "-body", compact=options.detached, safeBottom=(safeBottom and not options.detached), expanded=expanded, expandOnScroll=options.expandOnScroll, expand=expandPage)
                  children
              else
                children

component DrawerBody
  props
    compact: bool
    id: string
    expanded: bool
    expandOnScroll: bool
    expand: action
  slot
  view
    DrawerBodySurface(id=id, compact=compact, safeBottom=false, expanded=expanded, expandOnScroll=expandOnScroll, expand=expand)
      children

component DrawerBodySurface
  props
    safeBottom: bool
    compact: bool
    id: string
    expanded: bool
    expandOnScroll: bool
    expand: action
  slot
  state dragging = false
  state previousTop = 0
  action beginScroll
    dragging = true
  action endScroll(e: ScrollDragEvent)
    dragging = false
  action moved(x: number, y: number)
    let upward = y > previousTop + 1
    previousTop = y
    if dragging and upward and expandOnScroll and not expanded and y > 8
      expand()
  action wheeled(e: WheelEvent)
    if not e.ctrlKey and expandOnScroll and not expanded and e.deltaY > 0
      expand()
  view
    scroll id=id testId=id flex="1 1 auto" min-height="0px" min-width="0px" overscroll-behavior="contain" scroll=moved scrolldragstart=beginScroll scrolldragend=endScroll wheel=wheeled
      column min-width="0px" width="100%" box-sizing="border-box" padding-bottom=(safeBottom ? "env(safe-area-inset-bottom, 0px)" : "0px")
        column min-width="0px" width="100%" box-sizing="border-box" padding=(compact ? "0px ui.drawer-floating-content-inset ui.drawer-floating-content-inset" : "0px ui.drawer-content-inset ui.drawer-content-inset") gap="ui.space-12"
          children

component DrawerInset
  props
    compact: bool
  slot
  view
    column min-width="0px" width="100%" box-sizing="border-box" padding=(compact ? "ui.drawer-floating-content-inset" : "ui.drawer-content-inset") gap="ui.space-12"
      children

component DrawerFooter
  props
    compact: bool
  slot
  view
    column min-width="0px" flex-shrink=0 box-sizing="border-box" padding=(compact ? "ui.drawer-floating-content-inset" : "ui.drawer-content-inset") gap="ui.space-8"
      children

```
