suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
GitHubGet started
DocsComponentsPatternsInteractionsChartsBlocks
Components82
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Wheel Picker
  • Widget

suiss/ui · Component

Drawer

A panel that slides in from an edge of the screen and can be dismissed with a swipe.

Drawer is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

export default function DrawerDemo() {
  return (
    <Drawer swipeDirection="down" floating={false} showSwipeHandle modal>
      <DrawerTrigger render={<Button variant="outline" />}>
        Open drawer
      </DrawerTrigger>
      <DrawerContent>
        <DrawerHeader>
          <DrawerTitle>Move goal</DrawerTitle>
          <DrawerDescription>Set your daily activity goal.</DrawerDescription>
        </DrawerHeader>
        <div className="flex flex-col items-center gap-1 p-4">
          <span className="text-5xl font-semibold tracking-tight">350</span>
          <span className="text-muted-foreground text-xs uppercase">
            Calories per day
          </span>
        </div>
        <DrawerFooter>
          <Button>Save goal</Button>
          <DrawerClose render={<Button variant="outline" />}>
            Cancel
          </DrawerClose>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  )
}

Drawer wraps the Base UI Drawer. The Drawer root manages the open state and the swipe direction, and DrawerTrigger opens it. DrawerContent renders the panel in a portal, over a dimmed DrawerOverlay when modal, with an optional swipe handle and close button. Inside it, DrawerHeader holds the DrawerTitle and DrawerDescription, and DrawerFooter holds the actions. DrawerClose closes the drawer from any element.

The drawer opens from the bottom by default and can also open from the top, left or right. It supports snap points, a floating style inset from the screen edges, and a non-modal mode. To get the iOS sheet effect, where the page behind scales down as a bottom drawer opens, wrap the page in DrawerProvider with DrawerIndentBackground and DrawerIndent. Use a drawer for touch-friendly, swipeable panels; for a centered window, use a dialog.

Installation

CLI

$ pnpm dlx shadcn@latest add @esuiss/drawer

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add drawer

Manual

  1. Install the dependencies and add the cn helper:
$ pnpm add @base-ui/react @phosphor-icons/react
  1. Add the pieces it builds on: Button, use-scrollbar-gap.

  2. Copy the source into components/ui/drawer.tsx:

components/ui/drawer.tsx
"use client"

import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer"
import { XIcon } from "@phosphor-icons/react"
import * as React from "react"
import { Button } from "@/components/ui/button"
import { useScrollbarGap } from "@/hooks/use-scrollbar-gap"
import { cn } from "@/lib/utils"

type DrawerContextProps = {
  floating: boolean
  hasSnapPoints: boolean
  modal: DrawerPrimitive.Root.Props["modal"]
  showSwipeHandle: boolean
  swipeDirection: NonNullable<DrawerPrimitive.Root.Props["swipeDirection"]>
}
  1. Update the import paths to match your project.

Usage

import { DrawerProvider, DrawerIndentBackground, DrawerIndent, Drawer, DrawerTrigger, DrawerPortal, DrawerClose, DrawerOverlay, DrawerSwipeHandle, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription } from "@/components/ui/drawer"
<Drawer swipeDirection="down" showSwipeHandle modal>
  <DrawerTrigger render={<Button variant="outline" />}>
    Open drawer
  </DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Move goal</DrawerTitle>
      <DrawerDescription>Set your daily activity goal.</DrawerDescription>
    </DrawerHeader>
    <div className="flex flex-col items-center gap-1 p-4">
      <span className="text-5xl font-semibold tracking-tight">350</span>
      <span className="text-muted-foreground text-xs uppercase">
        Calories per day
      </span>
    </div>
    <DrawerFooter>
      <Button>Save goal</Button>
      <DrawerClose render={<Button variant="outline" />}>
        Cancel
      </DrawerClose>
    </DrawerFooter>
  </DrawerContent>
</Drawer>

The drawer is uncontrolled by default; set defaultOpen to start open, or control it with open and onOpenChange. Set swipeDirection to down, up, left or right to choose the edge it opens from and the direction it is swiped to close.

Pass snapPoints, such as [0.5, 1], to let people drag the drawer between heights; it opens at the first snap point unless you set defaultSnapPoint, or control it with snapPoint and onSnapPointChange. Set modal={false} to keep the rest of the page interactive; no overlay is rendered in that case.

For the indented page effect, place DrawerIndentBackground and DrawerIndent inside DrawerProvider and put the page content in DrawerIndent. The page is scaled while a non-floating drawer that opens from the bottom is open, and, with snap points, only at the last snap point.

Examples

Directions

Four drawers that open from the bottom, top, left and right edges.

import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

export default function DrawerDirections() {
  return (
    <div className="flex flex-wrap items-center gap-3">
      {(["down", "up", "left", "right"] as const).map((direction) => (
        <Drawer
          key={direction}
          floating={false}
          showSwipeHandle
          modal
          swipeDirection={direction}
        >
          <DrawerTrigger render={<Button variant="outline" />}>
            {direction.charAt(0).toUpperCase() + direction.slice(1)}
          </DrawerTrigger>
          <DrawerContent>
            <DrawerHeader>
              <DrawerTitle>Notifications</DrawerTitle>
              <DrawerDescription>
                You have three unread messages.
              </DrawerDescription>
            </DrawerHeader>
            <DrawerFooter className="pt-4">
              <DrawerClose render={<Button variant="outline" />}>
                Close
              </DrawerClose>
            </DrawerFooter>
          </DrawerContent>
        </Drawer>
      ))}
    </div>
  )
}

With close button

A drawer with an icon close button in the top corner.

import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

export default function DrawerWithCloseButton() {
  return (
    <Drawer swipeDirection="down" floating={false} showSwipeHandle modal>
      <DrawerTrigger render={<Button variant="outline" />}>
        Open drawer
      </DrawerTrigger>
      <DrawerContent showCloseButton>
        <DrawerHeader>
          <DrawerTitle>Move goal</DrawerTitle>
          <DrawerDescription>Set your daily activity goal.</DrawerDescription>
        </DrawerHeader>
        <div className="flex flex-col items-center gap-1 p-4">
          <span className="text-5xl font-semibold tracking-tight">350</span>
          <span className="text-muted-foreground text-xs uppercase">
            Calories per day
          </span>
        </div>
        <DrawerFooter>
          <Button>Save goal</Button>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  )
}

With close label

A drawer whose close button shows a text label instead of an icon.

import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

export default function DrawerWithCloseLabel() {
  return (
    <Drawer swipeDirection="down" floating={false} showSwipeHandle modal>
      <DrawerTrigger render={<Button variant="outline" />}>
        Open drawer
      </DrawerTrigger>
      <DrawerContent showCloseButton closeLabel="Close">
        <DrawerHeader>
          <DrawerTitle>Move goal</DrawerTitle>
          <DrawerDescription>Set your daily activity goal.</DrawerDescription>
        </DrawerHeader>
        <div className="flex flex-col items-center gap-1 p-4">
          <span className="text-5xl font-semibold tracking-tight">350</span>
          <span className="text-muted-foreground text-xs uppercase">
            Calories per day
          </span>
        </div>
        <DrawerFooter>
          <Button>Save goal</Button>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  )
}

Floating

A floating drawer, inset from the screen edges with rounded corners on all sides.

import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

export default function DrawerFloating() {
  return (
    <Drawer swipeDirection="down" floating showSwipeHandle modal>
      <DrawerTrigger render={<Button variant="outline" />}>
        Open drawer
      </DrawerTrigger>
      <DrawerContent>
        <DrawerHeader>
          <DrawerTitle>Move goal</DrawerTitle>
          <DrawerDescription>Set your daily activity goal.</DrawerDescription>
        </DrawerHeader>
        <div className="flex flex-col items-center gap-1 p-4">
          <span className="text-5xl font-semibold tracking-tight">350</span>
          <span className="text-muted-foreground text-xs uppercase">
            Calories per day
          </span>
        </div>
        <DrawerFooter>
          <Button>Save goal</Button>
          <DrawerClose render={<Button variant="outline" />}>
            Cancel
          </DrawerClose>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  )
}

With snap points

A drawer that opens at half height and expands when dragged up.

import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

export default function DrawerWithSnapPoints() {
  return (
    <Drawer
      swipeDirection="down"
      floating={false}
      showSwipeHandle
      modal
      snapPoints={[0.5, 1]}
    >
      <DrawerTrigger render={<Button variant="outline" />}>
        Open drawer
      </DrawerTrigger>
      <DrawerContent>
        <DrawerHeader>
          <DrawerTitle>Move goal</DrawerTitle>
          <DrawerDescription>Set your daily activity goal.</DrawerDescription>
        </DrawerHeader>
        <div className="flex flex-col items-center gap-1 p-4">
          <span className="text-5xl font-semibold tracking-tight">350</span>
          <span className="text-muted-foreground text-xs uppercase">
            Calories per day
          </span>
        </div>
        <DrawerFooter>
          <Button>Save goal</Button>
          <DrawerClose render={<Button variant="outline" />}>
            Cancel
          </DrawerClose>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  )
}

Non modal

A non-modal drawer that leaves the rest of the page interactive.

import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

export default function DrawerNonModal() {
  return (
    <Drawer
      swipeDirection="down"
      floating={false}
      showSwipeHandle
      modal={false}
    >
      <DrawerTrigger render={<Button variant="outline" />}>
        Open drawer
      </DrawerTrigger>
      <DrawerContent>
        <DrawerHeader>
          <DrawerTitle>Move goal</DrawerTitle>
          <DrawerDescription>Set your daily activity goal.</DrawerDescription>
        </DrawerHeader>
        <div className="flex flex-col items-center gap-1 p-4">
          <span className="text-5xl font-semibold tracking-tight">350</span>
          <span className="text-muted-foreground text-xs uppercase">
            Calories per day
          </span>
        </div>
        <DrawerFooter>
          <Button>Save goal</Button>
          <DrawerClose render={<Button variant="outline" />}>
            Cancel
          </DrawerClose>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  )
}

Sheet with detents

An iOS-style event sheet with snap points that scales the page behind it using DrawerIndent.

import { PlusIcon } from "@phosphor-icons/react"
import * as React from "react"
import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerIndent,
  DrawerIndentBackground,
  DrawerProvider,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"
import { Input } from "@/components/ui/input"
import { Switch } from "@/components/ui/switch"

const days = Array.from({ length: 35 }, (_, index) => index - 2)

const weekdays = [
  "Sunday",
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
]

function CalendarExample() {
  const [open, setOpen] = React.useState(false)
  const [allDay, setAllDay] = React.useState(false)

  return (
    <DrawerProvider>
      <DrawerIndentBackground />
      <DrawerIndent className="flex flex-col px-4 pt-6 pb-10">
        <div className="mx-auto flex w-full max-w-md flex-col gap-4">
          <div className="flex items-center justify-between">
            <h2 className="text-3xl font-bold tracking-tight">October</h2>
            <Drawer
              open={open}
              onOpenChange={setOpen}
              snapPoints={[0.5, 1]}
              showSwipeHandle
            >
              <DrawerTrigger
                render={
                  <Button
                    variant="plain"
                    size="icon-lg"
                    aria-label="New event"
                  />
                }
              >
                <PlusIcon className="size-5.5" />
              </DrawerTrigger>
              <DrawerContent>
                <div className="flex items-center justify-between px-2 pt-1">
                  <DrawerClose render={<Button variant="plain" />}>
                    Cancel
                  </DrawerClose>
                  <DrawerTitle>New Event</DrawerTitle>
                  <Button
                    variant="plain"
                    className="font-semibold"
                    onClick={() => setOpen(false)}
                  >
                    Add
                  </Button>
                </div>
                <DrawerDescription className="sr-only">
                  Drag the handle up for the full form.
                </DrawerDescription>
                <div className="flex flex-col gap-4 overflow-y-auto p-4">
                  <div className="flex flex-col overflow-hidden rounded-xl bg-muted">
                    <Input
                      aria-label="Title"
                      placeholder="Title"
                      className="rounded-none border-0 bg-transparent"
                    />
                    <Input
                      aria-label="Location"
                      placeholder="Location or Video Call"
                      className="rounded-none border-0 border-t border-border bg-transparent"
                    />
                  </div>
                  <div className="flex flex-col divide-y divide-border overflow-hidden rounded-xl bg-muted">
                    <div className="flex min-h-11 items-center justify-between px-3 text-base">
                      <span id="all-day-label">All-day</span>
                      <Switch
                        aria-labelledby="all-day-label"
                        checked={allDay}
                        onCheckedChange={setAllDay}
                      />
                    </div>
                    <div className="flex min-h-11 items-center justify-between px-3 text-base">
                      Starts
                      <span className="text-muted-foreground">
                        {allDay ? "Oct 14" : "Oct 14, 9:00 AM"}
                      </span>
                    </div>
                    <div className="flex min-h-11 items-center justify-between px-3 text-base">
                      Ends
                      <span className="text-muted-foreground">
                        {allDay ? "Oct 14" : "Oct 14, 10:00 AM"}
                      </span>
                    </div>
                  </div>
                  <textarea
                    aria-label="Notes"
                    placeholder="Notes"
                    rows={6}
                    className="resize-none rounded-xl bg-muted p-3 text-base outline-none placeholder:text-muted-foreground focus-visible:ring-3 focus-visible:ring-ring/50"
                  />
                </div>
              </DrawerContent>
            </Drawer>
          </div>
          <div className="grid grid-cols-7 gap-y-3 text-center text-sm">
            {weekdays.map((day) => (
              <abbr
                key={day}
                title={day}
                className="text-xs font-semibold text-muted-foreground no-underline"
              >
                {day[0]}
              </abbr>
            ))}
            {days.map((day) => (
              <span
                key={day}
                className={
                  day === 14
                    ? "mx-auto flex size-9 items-center justify-center rounded-full bg-destructive font-semibold text-background"
                    : "flex h-9 items-center justify-center"
                }
              >
                {day > 0 && day <= 31 ? day : ""}
              </span>
            ))}
          </div>
          <div className="flex flex-col gap-2 rounded-2xl bg-muted p-4">
            <span className="text-sm font-semibold">Tuesday, October 14</span>
            <span className="text-sm text-muted-foreground">
              9:00 AM · Design review
            </span>
            <span className="text-sm text-muted-foreground">
              1:00 PM · Lunch with Sam
            </span>
          </div>
        </div>
      </DrawerIndent>
    </DrawerProvider>
  )
}

export default function DrawerSheetWithDetents() {
  return <CalendarExample />
}

API Reference

Anatomy8 parts
<Drawer>
<DrawerTrigger />
<DrawerContent>
<DrawerHeader>
<DrawerTitle />
<DrawerDescription />
</DrawerHeader>
<DrawerFooter>
<DrawerClose />
</DrawerFooter>
</DrawerContent>
</Drawer>
01

DrawerProvider

Coordinates drawers with DrawerIndent so the page can react when a drawer opens.

Also accepts the props of DrawerPrimitive.Provider.Props.

02

DrawerIndentBackground

The dark layer shown behind the page when it scales down.

Also accepts the props of DrawerPrimitive.IndentBackground.Props.

03

DrawerIndent

Wraps the page content and scales it down while a bottom drawer is open.

Also accepts the props of DrawerPrimitive.Indent.Props.

04

Drawer

The root that manages the open state, swipe direction and snap points.

PropTypeDefaultDescription
floatingbooleanfalseInsets the drawer from the screen edges and rounds all of its corners.
showSwipeHandlebooleanfalseShows a grab bar on the edge of the panel that faces the screen center.

Also accepts the props of DrawerPrimitive.Root.Props.

05

DrawerTrigger

The button that opens the drawer.

Also accepts the props of DrawerPrimitive.Trigger.Props.

06

DrawerPortal

Renders its children into a portal outside the current DOM hierarchy.

Also accepts the props of DrawerPrimitive.Portal.Props.

07

DrawerClose

A button that closes the drawer.

Also accepts the props of DrawerPrimitive.Close.Props.

08

DrawerOverlay

The dimmed layer behind a modal drawer, which fades as the drawer is swiped away.

Also accepts the props of DrawerPrimitive.Backdrop.Props.

09

DrawerSwipeHandle

The grab bar people drag to move or dismiss the drawer.

Also accepts the props of React.ComponentProps<"div">.

10

DrawerContent

The drawer panel, rendered in a portal with an optional overlay, swipe handle and close button.

PropTypeDefaultDescription
showCloseButtonbooleanfalseShows a close button in the top corner.
closeLabelstring-Replaces the close button's icon with this text.

Also accepts the props of DrawerPrimitive.Popup.Props.

11

DrawerHeader

Groups the title and description.

Also accepts the props of React.ComponentProps<"div">.

12

DrawerFooter

Holds the drawer's actions at the bottom of the panel.

Also accepts the props of React.ComponentProps<"div">.

13

DrawerTitle

The drawer's title, which also names it for assistive technology.

Also accepts the props of DrawerPrimitive.Title.Props.

14

DrawerDescription

Supporting text that describes the drawer for assistive technology.

Also accepts the props of DrawerPrimitive.Description.Props.

Accessibility

  • The panel has the dialog role. DrawerTitle provides its accessible name and DrawerDescription its accessible description.
  • Opening the drawer moves focus inside it. Escape closes it and returns focus to the trigger.
  • A non-modal drawer does not set aria-modal.
  • The swipe handle is hidden from assistive technology, so always provide another way to close the drawer, such as a DrawerClose button.
  • The icon-only close button has a visually hidden Close label.

Notes

  • Styling hooks: data-slot values such as drawer-popup, drawer-content, drawer-overlay, drawer-swipe-handle, drawer-close-button, drawer-header, drawer-footer and drawer-indent.
  • The panel sets data-swipe-direction, data-swipe-axis, and, when applicable, data-floating and data-snap-points. A drawer at its last snap point gets data-expanded. DrawerIndent gets data-raised while the page is scaled.
  • Side drawers are 75% wide, and 24rem wide from the sm breakpoint. Top and bottom drawers are limited to the viewport height minus 6rem.
  • Nested drawers stack, with the drawer behind scaled down slightly.
  • Uses the popover, background and border colors, with a bg-black/50 backdrop. Animations are disabled on DrawerIndent when reduced motion is preferred.
iOS
Drawer (open by default) on iOS in light modeDrawer (open by default) on iOS in dark mode
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from "@/components/ui/drawer"
import { Text } from "@/components/ui/text"

function GoalContent() {
  return (
    <DrawerContent>
      <DrawerHeader>
        <DrawerTitle>Move goal</DrawerTitle>
        <DrawerDescription>Set your daily activity goal.</DrawerDescription>
      </DrawerHeader>
      <View className="items-center gap-1 p-4">
        <Text className="text-5xl font-semibold tracking-tight">350</Text>
        <Text className="text-xs text-muted-foreground uppercase">
          Calories/day
        </Text>
      </View>
      <DrawerFooter>
        <Button>
          <Text>Submit</Text>
        </Button>
        <DrawerClose render={<Button variant="secondary" />}>
          <Text>Cancel</Text>
        </DrawerClose>
      </DrawerFooter>
    </DrawerContent>
  )
}

export function DrawerOpenByDefaultExample() {
  return (
    <View className="items-start">
      <Drawer defaultOpen showSwipeHandle>
        <DrawerTrigger render={<Button variant="outline" />}>
          <Text>Open drawer</Text>
        </DrawerTrigger>
        <GoalContent />
      </Drawer>
    </View>
  )
}
import EsuissUI
import SwiftUI

struct DrawerOpenByDefaultExample: View {
  var body: some View {
    DrawerGoal(open: true)
  }
}

struct DrawerGoal: View {
  @State private var open: Bool

  init(open: Bool = false) {
    _open = State(initialValue: open)
  }

  var body: some View {
    Button("Open drawer") { open = true }
      .buttonStyle(.variant(.outline))
      .drawer(isPresented: $open) {
        DrawerGoalContent()
      }
  }
}

struct DrawerGoalContent: View {
  var body: some View {
    DrawerContent {
      DrawerHeader {
        DrawerTitle("Move goal")
        DrawerDescription("Set your daily activity goal.")
      }
      VStack(spacing: 4) {
        Text(verbatim: "350")
          .font(.system(size: 48, weight: .semibold))
          .tracking(-1.2)
          .foregroundStyle(EsuissColor.foreground)
        Text("Calories/day")
          .textCase(.uppercase)
          .textStyle(.xs)
          .foregroundStyle(EsuissColor.mutedForeground)
      }
      .frame(maxWidth: .infinity)
      .padding(16)
      DrawerFooter {
        Button {} label: {
          Text("Submit").frame(maxWidth: .infinity)
        }
        .buttonStyle(.variant())
        DrawerClose {
          Text("Cancel").frame(maxWidth: .infinity)
        }
        .buttonStyle(.variant(.secondary))
      }
    }
  }
}
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Drawer

@Composable
fun DrawerOpenByDefaultExample() {
    DrawerGoal(defaultOpen = true, floating = false)
}

@Composable
fun DrawerGoal(defaultOpen: Boolean, floating: Boolean, label: String = "Open drawer") {
    var open by rememberSaveable { mutableStateOf(defaultOpen) }
    Column {
        Button(label, onClick = { open = true }, variant = ButtonVariant.Outline)
        Drawer(open = open, onOpenChange = { open = it }, floating = floating, showSwipeHandle = true) {
            DrawerGoalContent(onClose = { open = false })
        }
    }
}

Drawer presents content in a panel attached to an edge of the screen. It slides in from the bottom by default, or from the top, left or right with swipeDirection, and the user can drag it closed in that direction. The content renders through a portal (inside a full-window overlay on iOS) and respects the safe-area insets.

Set floating to inset the panel from the screen edges with all corners rounded. Use snapPoints to let a bottom drawer rest at several heights. Wrap your app in DrawerProvider and its screen in DrawerIndent to scale the page back behind an open bottom drawer.

Installation

$ pnpm dlx shadcn@latest add @esuiss-rn/drawer

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add drawer
$ pnpm dlx @esuiss/ui@latest add drawer --platform swift
$ pnpm dlx @esuiss/ui@latest add drawer --platform kotlin

The CLI also adds what it builds on: Button, Icon, Text. On React Native it also adds the animated view components/ui/animated-view.tsx.

Manual

  1. Install the dependencies:
npx expo install cn phosphor-react-native react-native-reanimated react-native-safe-area-context react-native-screens react-native-svg react-native-worklets
  1. Add the pieces it builds on: Button, Icon, Text, and the primitives components/primitives/drawer.tsx, components/primitives/use-render.tsx, and the animated view components/ui/animated-view.tsx from the next step.

  2. Copy the animated view into components/ui/animated-view.tsx:

uniwind/components/ui/animated-view.tsx
import { Pressable } from "react-native"
import Animated from "react-native-reanimated"

const AnimatedPressable = Animated.createAnimatedComponent(Pressable)

type AnimatedViewProps =
  | (React.ComponentProps<typeof Animated.View> &
      React.RefAttributes<React.ComponentRef<typeof Animated.View>> & {
        as?: "View"
      })
  | (React.ComponentProps<typeof AnimatedPressable> &
      React.RefAttributes<React.ComponentRef<typeof AnimatedPressable>> & {
        as: "Pressable"
      })

function AnimatedView(props: AnimatedViewProps) {
  1. Copy the source into components/ui/drawer.tsx:
uniwind/components/ui/drawer.tsx
import { cn } from "cn"
import { XIcon } from "phosphor-react-native"
import * as React from "react"
import {
  Platform,
  useWindowDimensions,
  View,
  type ViewProps,
  type ViewStyle,
} from "react-native"
import {
  FadeIn,
  FadeOut,
  ReduceMotion,
  SlideInDown,
  SlideInLeft,
  1. Update the import paths to match your project.
  1. Install the dependencies:
npx expo install cn phosphor-react-native react-native-reanimated react-native-safe-area-context react-native-screens react-native-svg react-native-worklets
  1. Add the pieces it builds on: Button, Icon, Text, and the primitives components/primitives/drawer.tsx, components/primitives/use-render.tsx, and the animated view components/ui/animated-view.tsx from the next step.

  2. Copy the animated view into components/ui/animated-view.tsx:

nativewind/components/ui/animated-view.tsx
import { Pressable } from "react-native"
import Animated from "react-native-reanimated"

const AnimatedPressable = Animated.createAnimatedComponent(Pressable)

type AnimatedViewProps =
  | (React.ComponentProps<typeof Animated.View> &
      React.RefAttributes<React.ComponentRef<typeof Animated.View>> & {
        as?: "View"
      })
  | (React.ComponentProps<typeof AnimatedPressable> &
      React.RefAttributes<React.ComponentRef<typeof AnimatedPressable>> & {
        as: "Pressable"
      })

function AnimatedView(props: AnimatedViewProps) {
  1. Copy the source into components/ui/drawer.tsx:
nativewind/components/ui/drawer.tsx
import { cn } from "cn"
import { XIcon } from "phosphor-react-native"
import * as React from "react"
import {
  Platform,
  useWindowDimensions,
  View,
  type ViewProps,
  type ViewStyle,
} from "react-native"
import {
  FadeIn,
  FadeOut,
  ReduceMotion,
  SlideInDown,
  SlideInLeft,
  1. Update the import paths to match your project.
  1. Install the dependencies:
npx expo install phosphor-react-native react-native-reanimated react-native-safe-area-context react-native-screens react-native-svg react-native-worklets
  1. Add the pieces it builds on: Button, Icon, Text, and the primitives components/primitives/drawer.tsx, components/primitives/use-render.tsx, and the animated view components/ui/animated-view.tsx from the next step.

  2. Copy the animated view into components/ui/animated-view.tsx:

stylesheet/components/ui/animated-view.tsx
import { Pressable } from "react-native"
import Animated from "react-native-reanimated"

const AnimatedPressable = Animated.createAnimatedComponent(Pressable)

type AnimatedViewProps =
  | (React.ComponentProps<typeof Animated.View> &
      React.RefAttributes<React.ComponentRef<typeof Animated.View>> & {
        as?: "View"
      })
  | (React.ComponentProps<typeof AnimatedPressable> &
      React.RefAttributes<React.ComponentRef<typeof AnimatedPressable>> & {
        as: "Pressable"
      })

function AnimatedView(props: AnimatedViewProps) {
  1. Copy the source into components/ui/drawer.tsx:
stylesheet/components/ui/drawer.tsx
import { XIcon } from "phosphor-react-native"
import * as React from "react"
import {
  Platform,
  StyleSheet,
  useWindowDimensions,
  View,
  type ViewProps,
  type ViewStyle,
} from "react-native"
import {
  FadeIn,
  FadeOut,
  ReduceMotion,
  SlideInDown,
  SlideInLeft,
  1. Update the import paths to match your project.
  1. Target iOS 17 or later.

  2. Add the Swift package to your app:

Package.swift
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
  1. Copy the theme files every view uses:
swift/Theme/Theme.swift
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x2997FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0xA1A1A6))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source and every file it uses:
swift/Components/Drawer.swift
import SwiftUI

extension View {
  public func drawer<Content: View>(
    isPresented: Binding<Bool>,
    detents: Set<PresentationDetent>? = nil,
    selection: Binding<PresentationDetent>? = nil,
    onDismiss: (() -> Void)? = nil,
    @ViewBuilder content: @escaping () -> Content
  ) -> some View {
    let binding = isPresented
    return sheet(isPresented: isPresented, onDismiss: onDismiss) {
      DrawerHost(detents: detents, selection: selection, content: content)
        .environment(\.overlayDismiss, OverlayDismiss { binding.wrappedValue = false })
    }
  }
swift/Components/Button.swift
import SwiftUI

public struct VariantButtonStyle: ButtonStyle {
  public enum Variant: CaseIterable, Sendable {
    case `default`, outline, secondary, tinted, ghost, plain, destructive, link
  }

  public enum Size: CaseIterable, Sendable {
    case `default`, xs, sm, lg, xl, icon, iconXs, iconSm, iconLg, iconXl

    var height: CGFloat {
      switch self {
      case .xs, .iconXs: 24
      case .sm, .iconSm: 32
      case .default, .icon: 36
      case .lg, .iconLg: 44
swift/Components/ButtonGroup.swift
import SwiftUI

extension EnvironmentValues {
  @Entry var buttonGroup: Axis? = nil
  @Entry var buttonGroupSize: CGSize = .zero
}

enum ButtonGroupSpace: Hashable {
  case group
}

struct ButtonGroupFrame {
  let bounds: Anchor<CGRect>
  let outlined: Bool
}
swift/Components/Dialog.swift
import SwiftUI

extension View {
  public func dialog<Content: View>(
    isPresented: Binding<Bool>,
    @ViewBuilder content: @escaping () -> Content
  ) -> some View {
    modifier(
      CoverPresenter(isPresented: isPresented) { visible in
        CenteredStage(visible: visible, dismissible: true, content: content)
      }
    )
  }
}

struct CenteredStage<Content: View>: View {
swift/Components/Overlay.swift
import PhosphorSwift
import Observation
import SwiftUI

public enum PopupAlignment: Sendable, CaseIterable {
  case start, center, end
}

struct OverlayDismiss: Sendable {
  let action: @MainActor @Sendable () -> Void

  @MainActor func callAsFunction() {
    action()
  }
}
swift/Components/TextVariant.swift
import SwiftUI

public enum TextVariant: CaseIterable, Sendable {
  case `default`, h1, h2, h3, h4, p, blockquote, code, lead, large, small, muted

  var style: TextStyle {
    switch self {
    case .h1: .xl3
    case .h2: .xl2
    case .h3: .xl
    case .h4, .lead, .large: .lg
    case .code, .small, .muted: .sm
    default: .base
    }
  }
  1. Add the files to your app target.
  1. Set minSdk to 24 or higher and add the dependencies:
build.gradle.kts
implementation(platform("androidx.compose:compose-bom:2026.09.00"))
implementation("androidx.compose.foundation:foundation")
implementation("androidx.compose.ui:ui")
implementation("com.adamglin:phosphor-icon-android:1.0.0")
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.LineHeightStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpOffset
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
    val primaryForeground: Color,
  1. Copy the source and every file it uses:
kotlin/components/Drawer.kt
package com.esuiss.ui.components

import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.AnchoredDraggableDefaults
import androidx.compose.foundation.gestures.AnchoredDraggableState
import androidx.compose.foundation.gestures.DraggableAnchors
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.anchoredDraggable
import androidx.compose.foundation.gestures.animateTo
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
kotlin/components/Button.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
kotlin/components/ButtonGroup.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/Icon.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Icon(
    imageVector: ImageVector,
kotlin/components/Overlay.kt
package com.esuiss.ui.components

import android.os.Build
import android.view.Window
import android.view.WindowManager
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.EnterExitState
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.animation.slideIn
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { DrawerProvider, DrawerIndentBackground, DrawerIndent, Drawer, DrawerOverlay, DrawerSwipeHandle, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription } from "@/components/ui/drawer"
<View className="items-start">
  <Drawer defaultOpen showSwipeHandle>
    <DrawerTrigger render={<Button variant="outline" />}>
      <Text>Open drawer</Text>
    </DrawerTrigger>
    <GoalContent />
  </Drawer>
</View>

Compose DrawerTrigger and DrawerContent with a DrawerHeader (DrawerTitle, DrawerDescription), your content and a DrawerFooter. Use DrawerClose to close it from a button.

Set showSwipeHandle to show a grab handle, and showCloseButton on the content for a corner close button, with closeLabel for a text button. snapPoints accepts fractions of the screen such as [0.4, 1]; control the current one with snapPoint and onSnapPointChange.

With modal={false} there is no scrim. For the scaled background, render DrawerIndentBackground behind a DrawerIndent inside DrawerProvider.

Examples

Default

iOS
Drawer on iOS in light modeDrawer on iOS in dark mode
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from "@/components/ui/drawer"
import { Text } from "@/components/ui/text"

function GoalContent() {
  return (
    <DrawerContent>
      <DrawerHeader>
        <DrawerTitle>Move goal</DrawerTitle>
        <DrawerDescription>Set your daily activity goal.</DrawerDescription>
      </DrawerHeader>
      <View className="items-center gap-1 p-4">
        <Text className="text-5xl font-semibold tracking-tight">350</Text>
        <Text className="text-xs text-muted-foreground uppercase">
          Calories/day
        </Text>
      </View>
      <DrawerFooter>
        <Button>
          <Text>Submit</Text>
        </Button>
        <DrawerClose render={<Button variant="secondary" />}>
          <Text>Cancel</Text>
        </DrawerClose>
      </DrawerFooter>
    </DrawerContent>
  )
}

export function DrawerExample() {
  return (
    <View className="items-start">
      <Drawer showSwipeHandle>
        <DrawerTrigger render={<Button variant="outline" />}>
          <Text>Open drawer</Text>
        </DrawerTrigger>
        <GoalContent />
      </Drawer>
    </View>
  )
}
import EsuissUI
import SwiftUI

struct DrawerGoal: View {
  @State private var open: Bool

  init(open: Bool = false) {
    _open = State(initialValue: open)
  }

  var body: some View {
    Button("Open drawer") { open = true }
      .buttonStyle(.variant(.outline))
      .drawer(isPresented: $open) {
        DrawerGoalContent()
      }
  }
}

struct DrawerGoalContent: View {
  var body: some View {
    DrawerContent {
      DrawerHeader {
        DrawerTitle("Move goal")
        DrawerDescription("Set your daily activity goal.")
      }
      VStack(spacing: 4) {
        Text(verbatim: "350")
          .font(.system(size: 48, weight: .semibold))
          .tracking(-1.2)
          .foregroundStyle(EsuissColor.foreground)
        Text("Calories/day")
          .textCase(.uppercase)
          .textStyle(.xs)
          .foregroundStyle(EsuissColor.mutedForeground)
      }
      .frame(maxWidth: .infinity)
      .padding(16)
      DrawerFooter {
        Button {} label: {
          Text("Submit").frame(maxWidth: .infinity)
        }
        .buttonStyle(.variant())
        DrawerClose {
          Text("Cancel").frame(maxWidth: .infinity)
        }
        .buttonStyle(.variant(.secondary))
      }
    }
  }
}
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Drawer

@Composable
fun DrawerExample() {
    DrawerGoal(defaultOpen = false, floating = false)
}

@Composable
fun DrawerGoal(defaultOpen: Boolean, floating: Boolean, label: String = "Open drawer") {
    var open by rememberSaveable { mutableStateOf(defaultOpen) }
    Column {
        Button(label, onClick = { open = true }, variant = ButtonVariant.Outline)
        Drawer(open = open, onOpenChange = { open = it }, floating = floating, showSwipeHandle = true) {
            DrawerGoalContent(onClose = { open = false })
        }
    }
}

Snap points

A drawer that rests at 40% and full height.

iOS
Drawer (snap points) on iOS in light modeDrawer (snap points) on iOS in dark mode
import { ScrollView, View } from "react-native"
import { Button } from "@/components/ui/button"
import { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle, DrawerTrigger } from "@/components/ui/drawer"
import { Text } from "@/components/ui/text"

const ITEMS = Array.from({ length: 20 }, (_, index) => `Item ${index + 1}`)

export function DrawerSnapPointsExample() {
  return (
    <View className="items-start">
      <Drawer snapPoints={[0.4, 1]} showSwipeHandle>
        <DrawerTrigger render={<Button variant="outline" />}>
          <Text>Open with snap points</Text>
        </DrawerTrigger>
        <DrawerContent showCloseButton>
          <DrawerHeader>
            <DrawerTitle>Snap points</DrawerTitle>
            <DrawerDescription>
              Drag up to expand, drag down to collapse or dismiss.
            </DrawerDescription>
          </DrawerHeader>
          <ScrollView contentContainerClassName="gap-3 p-4">
            {ITEMS.map((item) => (
              <View
                key={item}
                className="h-12 justify-center rounded-xl bg-muted px-4"
              >
                <Text>{item}</Text>
              </View>
            ))}
          </ScrollView>
        </DrawerContent>
      </Drawer>
    </View>
  )
}
import EsuissUI
import SwiftUI

struct DrawerSnapPoints: View {
  @State private var open = false

  var body: some View {
    Button("Open with snap points") { open = true }
      .buttonStyle(.variant(.outline))
      .drawer(isPresented: $open, detents: [.fraction(0.4), .large]) {
        DrawerContent(showCloseButton: true) {
          DrawerHeader {
            DrawerTitle("Snap points")
            DrawerDescription("Drag up to expand, drag down to collapse or dismiss.")
          }
          ScrollView {
            VStack(spacing: 12) {
              ForEach(1...20, id: \.self) { index in
                Text(verbatim: "Item \(index)")
                  .textStyle(.base)
                  .foregroundStyle(EsuissColor.foreground)
                  .padding(.horizontal, 16)
                  .frame(maxWidth: .infinity, minHeight: 48, alignment: .leading)
                  .background(EsuissColor.muted, in: RoundedRectangle(cornerRadius: Radius.xl, style: .continuous))
              }
            }
            .padding(16)
          }
        }
      }
  }
}
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Drawer
import com.esuiss.ui.components.DrawerDescription
import com.esuiss.ui.components.DrawerHeader
import com.esuiss.ui.components.DrawerTitle
import com.esuiss.ui.components.Text
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Radius

val DrawerItems = List(20) { "Item ${it + 1}" }

@Composable
fun DrawerSnapPoints() {
    var open by rememberSaveable { mutableStateOf(false) }
    Column {
        Button("Open with snap points", onClick = { open = true }, variant = ButtonVariant.Outline)
        Drawer(
            open = open,
            onOpenChange = { open = it },
            snapPoints = listOf(0.4f, 1f),
            showSwipeHandle = true,
            showCloseButton = true,
        ) {
            DrawerHeader {
                DrawerTitle("Snap points")
                DrawerDescription("Drag up to expand, drag down to collapse or dismiss.")
            }
            Column(
                modifier = Modifier
                    .weight(1f, fill = false)
                    .verticalScroll(rememberScrollState())
                    .padding(16.dp),
                verticalArrangement = Arrangement.spacedBy(12.dp),
            ) {
                DrawerItems.forEach { item ->
                    Box(
                        modifier = Modifier
                            .fillMaxWidth()
                            .height(48.dp)
                            .clip(RoundedCornerShape(Radius.xl))
                            .background(EsuissTheme.colors.muted)
                            .padding(horizontal = 16.dp),
                        contentAlignment = Alignment.CenterStart,
                    ) {
                        Text(item)
                    }
                }
            }
        }
    }
}

Floating

A floating drawer inset from the edges.

iOS
Drawer (floating) on iOS in light modeDrawer (floating) on iOS in dark mode
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from "@/components/ui/drawer"
import { Text } from "@/components/ui/text"

function GoalContent() {
  return (
    <DrawerContent>
      <DrawerHeader>
        <DrawerTitle>Move goal</DrawerTitle>
        <DrawerDescription>Set your daily activity goal.</DrawerDescription>
      </DrawerHeader>
      <View className="items-center gap-1 p-4">
        <Text className="text-5xl font-semibold tracking-tight">350</Text>
        <Text className="text-xs text-muted-foreground uppercase">
          Calories/day
        </Text>
      </View>
      <DrawerFooter>
        <Button>
          <Text>Submit</Text>
        </Button>
        <DrawerClose render={<Button variant="secondary" />}>
          <Text>Cancel</Text>
        </DrawerClose>
      </DrawerFooter>
    </DrawerContent>
  )
}

export function DrawerFloatingExample() {
  return (
    <View className="items-start">
      <Drawer floating showSwipeHandle>
        <DrawerTrigger render={<Button variant="outline" />}>
          <Text>Open floating drawer</Text>
        </DrawerTrigger>
        <GoalContent />
      </Drawer>
    </View>
  )
}
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Drawer

@Composable
fun DrawerFloatingExample() {
    DrawerGoal(defaultOpen = false, floating = true, label = "Open floating drawer")
}

@Composable
fun DrawerGoal(defaultOpen: Boolean, floating: Boolean, label: String = "Open drawer") {
    var open by rememberSaveable { mutableStateOf(defaultOpen) }
    Column {
        Button(label, onClick = { open = true }, variant = ButtonVariant.Outline)
        Drawer(open = open, onOpenChange = { open = it }, floating = floating, showSwipeHandle = true) {
            DrawerGoalContent(onClose = { open = false })
        }
    }
}

Sides

Drawers from the top, bottom, left and right.

iOS
Drawer (sides) on iOS in light modeDrawer (sides) on iOS in dark mode
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle, DrawerTrigger } from "@/components/ui/drawer"
import { Text } from "@/components/ui/text"

export function DrawerSidesExample() {
  return (
    <View className="items-start gap-3">
      {(["up", "right", "down", "left"] as const).map((direction) => (
        <Drawer key={direction} swipeDirection={direction} showSwipeHandle>
          <DrawerTrigger render={<Button variant="outline" />}>
            <Text>Swipe {direction}</Text>
          </DrawerTrigger>
          <DrawerContent showCloseButton closeLabel="Done">
            <DrawerHeader>
              <DrawerTitle>Swipe {direction} to close</DrawerTitle>
              <DrawerDescription>
                This drawer is dismissed by swiping {direction}.
              </DrawerDescription>
            </DrawerHeader>
            <View className="p-4">
              <Text className="text-sm text-muted-foreground">
                Android back and the VoiceOver escape gesture also close it.
              </Text>
            </View>
          </DrawerContent>
        </Drawer>
      ))}
    </View>
  )
}

API Reference

01

DrawerProvider

Tracks open drawers for the indent effect.

Also accepts the props of DrawerPrimitive.ProviderProps.

02

DrawerIndentBackground

Background shown behind the scaled screen.

Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.IndentBackground>.

03

DrawerIndent

Screen wrapper that scales back while a bottom drawer is open.

Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.Indent>.

04

Drawer

Root that holds the open state, direction and snap points.

PropTypeDefaultDescription
floatingbooleanfalseInsets the panel from the edges.
showSwipeHandlebooleanfalseShows a grab handle.

Also accepts the props of DrawerPrimitive.RootProps.

05

DrawerOverlay

Dimmed scrim behind a modal drawer.

Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.Backdrop>.

06

DrawerSwipeHandle

Grab handle on the dragging edge.

Also accepts the props of ViewProps.

07

DrawerContent

Sliding panel with optional handle and close button.

PropTypeDefaultDescription
portalHoststring-Name of the portal host to render into.
showCloseButtonbooleanfalseShows a corner close button.
closeLabelstring-Text for the close button instead of the icon.

Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.Popup>.

08

DrawerHeader

Area for the title and description.

Also accepts the props of ViewProps.

09

DrawerFooter

Area for actions at the end of the panel.

Also accepts the props of ViewProps.

10

DrawerTitle

Drawer heading, centered for top and bottom drawers.

Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.Title>.

11

DrawerDescription

Supporting text.

Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.Description>.

Accessibility

  • The popup has the dialog role and is labelled by the title.
  • The swipe handle and decorative edge fill are hidden from screen readers.
  • The icon close button is labelled "Close".

Notes

  • Padding follows the safe-area insets, and a docked drawer extends its background past the screen edge so drag overshoot shows no gap.
  • Animations respect the system Reduce Motion setting.
  • Uses bg-popover, bg-black/50 and bg-border tokens; light and dark follow the system appearance.
NextDropdown MenuPreviousDirection

On this page

  1. 01Installation
    • CLI
    • Manual
  2. 02Usage
  3. 03Examples
    • Directions
    • With close button
    • With close label
    • Floating
    • With snap points
    • Non modal
    • Sheet with detents
  4. 04API Reference
    • DrawerProvider
    • DrawerIndentBackground
    • DrawerIndent
    • Drawer
    • DrawerTrigger
    • DrawerPortal
    • DrawerClose
    • DrawerOverlay
    • DrawerSwipeHandle
    • DrawerContent
    • DrawerHeader
    • DrawerFooter
    • DrawerTitle
    • DrawerDescription
  5. 05Accessibility
  6. 06Notes
  7. 07Installation
    • Manual
  8. 08Usage
  9. 09Examples
    • Default
    • Snap points
    • Floating
    • Sides
  10. 10API Reference
    • DrawerProvider
    • DrawerIndentBackground
    • DrawerIndent
    • Drawer
    • DrawerOverlay
    • DrawerSwipeHandle
    • DrawerContent
    • DrawerHeader
    • DrawerFooter
    • DrawerTitle
    • DrawerDescription
  11. 11Accessibility
  12. 12Notes