# Drawer

- Page: https://jiguang132.com/resources/material-ui/docs/drawers
- Resource: Material UI (https://jiguang132.com/resources/material-ui.md)
- All guides: https://jiguang132.com/resources/material-ui/docs.md

Expose navigation or secondary tasks from an edge of the viewport.

This guide covers Material UI Core with the default Emotion engine; extensions and additional demos are explicitly classified.

## Use case and business boundary

Temporary and persistent variants have different modal behavior; swipe gestures do not replace keyboard close controls.

## Native composition and scope

`Drawer`, `SwipeableDrawer`

Preserve native Material UI composition and types; do not substitute JGuang UI/Base UI/Radix APIs. Example entries are not extra components.

## Native installation and initialization

```bash
npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1
```

Use native npm and Emotion, not an invented JGuang UI Registry URL. Place examples inside native ThemeProvider; choose CssBaseline or ScopedCssBaseline for the project. Inspect React, existing providers, lockfile and SSR first. Never overwrite files or conceal peer conflicts. This batch verified React 19.2.8; React 18 and below require matching react-is. See the included bilingual setup guide.

## Practical native parameters

These selected parameters are not a flattened universal API. Preserve the native declaring owner, slot structure, nullable values and generics.

| Owner.prop | Practical role | Declaration source |
| --- | --- | --- |
| `Drawer.open` | Controlled native visibility; it does not fetch data or execute actions. | `Drawer` |
| `Drawer.onClose` | Native request to close; reason/event signatures differ and the host updates open. | `Drawer` |
| `Drawer.variant` | Owning native presentation enum; never substitute a universal variant prop. | `Drawer` |
| `Drawer.anchor` | Native edge from which a Drawer appears. | `Drawer` |
| `SwipeableDrawer.onOpen` | Native opening request; keep the owning open state in sync. | `SwipeableDrawer` |

## Runnable native examples

Machine keys select example entries, not universal variant props. Native demo JSX/data stay unchanged; JGuang-authored acceptance fixtures are explicitly labelled.

- Temporary drawer · `TemporaryDrawer` · upstream native demo
- Anchor · `AnchorTemporaryDrawer` · upstream native demo
- Swipeable · `SwipeableTemporaryDrawer` · upstream native demo
- Swipeable edge · `SwipeableEdgeDrawer` · upstream native demo
- Responsive drawer · `ResponsiveDrawer` · upstream native demo
- Persistent drawer · `PersistentDrawerLeft` · upstream native demo
- Persistent drawer · `PersistentDrawerRight` · upstream native demo
- Mini variant drawer · `MiniDrawer` · upstream native demo
- Full-height navigation · `PermanentDrawerLeft` · upstream native demo
- Full-height navigation · `PermanentDrawerRight` · upstream native demo
- Clipped under the app bar · `ClippedDrawer` · upstream native demo

## Actual usage example

Unmodified pinned native demo; copy its required local helper files together.

```tsx
import * as React from 'react';
import Box from '@mui/material/Box';
import Drawer from '@mui/material/Drawer';
import Button from '@mui/material/Button';
import List from '@mui/material/List';
import Divider from '@mui/material/Divider';
import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import InboxIcon from '@mui/icons-material/MoveToInbox';
import MailIcon from '@mui/icons-material/Mail';

export default function TemporaryDrawer() {
  const [open, setOpen] = React.useState(false);

  const toggleDrawer = (newOpen: boolean) => () => {
    setOpen(newOpen);
  };

  const DrawerList = (
    <Box sx={{ width: 250 }} role="presentation" onClick={toggleDrawer(false)}>
      <List>
        {['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => (
          <ListItem key={text} disablePadding>
            <ListItemButton>
              <ListItemIcon>
                {index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
              </ListItemIcon>
              <ListItemText primary={text} />
            </ListItemButton>
          </ListItem>
        ))}
      </List>
      <Divider />
      <List>
        {['All mail', 'Trash', 'Spam'].map((text, index) => (
          <ListItem key={text} disablePadding>
            <ListItemButton>
              <ListItemIcon>
                {index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
              </ListItemIcon>
              <ListItemText primary={text} />
            </ListItemButton>
          </ListItem>
        ))}
      </List>
    </Box>
  );

  return (
    <div>
      <Button onClick={toggleDrawer(true)}>Open drawer</Button>
      <Drawer open={open} onClose={toggleDrawer(false)}>
        {DrawerList}
      </Drawer>
    </div>
  );
}

```

## Example dependency boundaries

`react`, `@mui/material/Box`, `@mui/material/Drawer`, `@mui/material/Button`, `@mui/material/List`, `@mui/material/Divider`, `@mui/material/ListItem`, `@mui/material/ListItemButton`, `@mui/material/ListItemIcon`, `@mui/material/ListItemText`, `@mui/icons-material/MoveToInbox`, `@mui/icons-material/Mail`, `@mui/material/SwipeableDrawer`, `@emotion/react`, `@mui/material/styles`, `@mui/material/CssBaseline`, `@mui/material/colors`, `@mui/material/Skeleton`, `@mui/material/Typography`, `@mui/material/AppBar`, `@mui/material/IconButton`, `@mui/icons-material/Menu`, `@mui/material/Toolbar`, `@mui/icons-material/ChevronLeft`, `@mui/icons-material/ChevronRight`

Direct Icons/System/Utils example imports require their matching 9.4.0 packages. Relative data/helpers are part of the example closure, not extra components. Remote images and simulated operations do not supply a backend.

## Pinned upstream API metadata reference

These tables retain the upstream metadata, not a newly inferred generic type system. Conditional generics, inherited props and callback details are defined by the source declarations below. Theme defaults may override metadata defaults.

### Drawer

```tsx
import Drawer from '@mui/material/Drawer';
import { Drawer } from '@mui/material';
```

| Prop | Required | Upstream metadata type / constraint | Metadata default |
| --- | --- | --- | --- |
| `anchor` | no | `'bottom' \| 'left' \| 'right' \| 'top'` | `'left'` |
| `children` | no | `node` | — |
| `classes` | no | `object` | — |
| `elevation` | no | `integer` | `16` |
| `hideBackdrop` | no | `bool` | `false` |
| `ModalProps` | no | `object` | `{}` |
| `onClose` | no | `func` | — |
| `open` | no | `bool` | `false` |
| `slotProps` | no | `{ backdrop?: func \| object, docked?: func \| object, paper?: func \| object, root?: func \| object, transition?: func \| object }` | `{}` |
| `slots` | no | `{ backdrop?: elementType, docked?: elementType, paper?: elementType, root?: elementType, transition?: elementType }` | `{}` |
| `sx` | no | `Array<func \| object \| bool> \| func \| object` | — |
| `transitionDuration` | no | `number \| { appear?: number, enter?: number, exit?: number }` | `{ enter: theme.transitions.duration.enteringScreen, exit: theme.transitions.duration.leavingScreen, }` |
| `variant` | no | `'permanent' \| 'persistent' \| 'temporary'` | `'temporary'` |



### SwipeableDrawer

```tsx
import SwipeableDrawer from '@mui/material/SwipeableDrawer';
import { SwipeableDrawer } from '@mui/material';
```

Native inheritance: `Drawer`. Parent/DOM props are not fabricated as additional own props.

| Prop | Required | Upstream metadata type / constraint | Metadata default |
| --- | --- | --- | --- |
| `onClose` | yes | `func` | — |
| `onOpen` | yes | `func` | — |
| `allowSwipeInChildren` | no | `func \| bool` | `false` |
| `children` | no | `node` | — |
| `disableBackdropTransition` | no | `bool` | `false` |
| `disableDiscovery` | no | `bool` | `false` |
| `disableSwipeToOpen` | no | `bool` | `typeof navigator !== 'undefined' && /iPad\|iPhone\|iPod/.test(navigator.userAgent)` |
| `hysteresis` | no | `number` | `0.52` |
| `minFlingVelocity` | no | `number` | `450` |
| `open` | no | `bool` | `false` |
| `slotProps` | no | `{ backdrop?: func \| object, docked?: func \| object, paper?: func \| object, root?: func \| object, swipeArea?: func \| object, transition?: func \| object }` | `{}` |
| `slots` | no | `{ backdrop?: elementType, docked?: elementType, paper?: elementType, root?: elementType, swipeArea?: elementType, transition?: elementType }` | `{}` |
| `swipeAreaWidth` | no | `number` | `20` |
| `transitionDuration` | no | `number \| { appear?: number, enter?: number, exit?: number }` | `{ enter: theme.transitions.duration.enteringScreen, exit: theme.transitions.duration.leavingScreen, }` |


## Native source declarations

Declarations/imports are extracted from pinned source without flattening unions or external inheritance. Original English comments/types are source reference, not a claim of translated upstream prose. Shared types stay in their native packages.

### vendor/src/Drawer/Drawer.d.ts

```ts
import * as React from 'react';

import { SxProps } from '@mui/system';

import { Theme } from '../styles';

import { InternalStandardProps as StandardProps } from '../internal';

import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';

import { ModalProps } from '../Modal';

import { BackdropProps } from '../Backdrop';

import { PaperProps } from '../Paper';

import { TransitionProps } from '../transitions/types';

import { DrawerClasses } from './drawerClasses';

export interface DrawerRootSlotPropsOverrides {}

export interface DrawerDockedSlotPropsOverrides {}

export interface DrawerPaperSlotPropsOverrides {}

export interface DrawerTransitionSlotPropsOverrides {}

export interface DrawerBackdropSlotPropsOverrides {}

export interface DrawerSlots {
  /**
   * The component used for the root when the variant is `temporary`.
   * @default Modal
   */
  root: React.ElementType;
  /**
   * The component used for the Modal backdrop.
   * @default Backdrop
   */
  backdrop: React.ElementType;
  /**
   * The component used for the root element when the variant is `permanent` or `persistent`.
   * @default div
   */
  docked: React.ElementType;
  /**
   * The component used for the paper.
   * @default Paper
   */
  paper: React.ElementType;
  /**
   * The component used for the transition.
   * [Follow this guide](/material-ui/transitions/#transition-slots) to learn more about the requirements for this component.
   * @default Slide
   */
  transition: React.ElementType;
}

export type DrawerSlotsAndSlotProps = CreateSlotsAndSlotProps<
  DrawerSlots,
  {
    /**
     * Props forwarded to the root slot.
     * By default, the available props are based on the [Modal](https://mui.com/material-ui/api/modal/#props) component.
     */
    root: SlotProps<React.ElementType<ModalProps>, DrawerRootSlotPropsOverrides, DrawerOwnerState>;
    /**
     * Props forwarded to the backdrop slot.
     * By default, the available props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
     */
    backdrop: SlotProps<
      React.ElementType<BackdropProps>,
      DrawerBackdropSlotPropsOverrides,
      DrawerOwnerState
    >;
    /**
     * Props forwarded to the docked slot.
     * By default, the available props are based on a div element.
     */
    docked: SlotProps<'div', DrawerDockedSlotPropsOverrides, DrawerOwnerState>;
    /**
     * Props forwarded to the paper slot.
     * By default, the available props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
     */
    paper: SlotProps<
      React.ElementType<PaperProps>,
      DrawerPaperSlotPropsOverrides,
      DrawerOwnerState
    >;
    /**
     * Props forwarded to the transition slot.
     * By default, the available props are based on the [Slide](https://mui.com/material-ui/api/slide/#props) component.
     */
    transition: SlotProps<
      React.ElementType<TransitionProps>,
      TransitionProps & DrawerTransitionSlotPropsOverrides,
      DrawerOwnerState
    >;
  }
>;

export interface DrawerProps
  extends
    StandardProps<ModalProps, 'open' | 'children' | 'slots' | 'slotProps'>,
    DrawerSlotsAndSlotProps {
  /**
   * Side from which the drawer will appear.
   * @default 'left'
   */
  anchor?: 'left' | 'top' | 'right' | 'bottom' | undefined;
  /**
   * The content of the component.
   */
  children?: React.ReactNode;
  /**
   * Override or extend the styles applied to the component.
   */
  classes?: Partial<DrawerClasses> | undefined;
  /**
   * The elevation of the drawer.
   * @default 16
   */
  elevation?: number | undefined;
  /**
   * Props applied to the [`Modal`](https://mui.com/material-ui/api/modal/) element.
   * @default {}
   */
  ModalProps?: Partial<ModalProps> | undefined;
  /**
   * Callback fired when the component requests to be closed.
   * The `reason` parameter can optionally be used to control the response to `onClose`.
   *
   * @param {object} event The event source of the callback.
   * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
   */
  onClose?: ModalProps['onClose'] | undefined;
  /**
   * If `true`, the component is shown.
   * @default false
   */
  open?: boolean | undefined;
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx?: SxProps<Theme> | undefined;
  /**
   * The duration for the transition, in milliseconds.
   * You may specify a single timeout for all transitions, or individually with an object.
   * @default {
   *   enter: theme.transitions.duration.enteringScreen,
   *   exit: theme.transitions.duration.leavingScreen,
   * }
   */
  transitionDuration?: TransitionProps['timeout'] | undefined;
  /**
   * The variant to use.
   * @default 'temporary'
   */
  variant?: 'permanent' | 'persistent' | 'temporary' | undefined;
}

export interface DrawerOwnerState extends Omit<DrawerProps, 'slots' | 'slotProps'> {}

export default function Drawer(props: DrawerProps): React.JSX.Element;
```

### vendor/src/SwipeableDrawer/SwipeableDrawer.d.ts

```ts
import * as React from 'react';

import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';

import { DrawerProps, DrawerOwnerState, DrawerSlotsAndSlotProps } from '../Drawer';

export interface SwipeableDrawerSwipeAreaSlotPropsOverrides {}

export interface SwipeableDrawerSlots {
  /**
   * The component used for the swipeArea slot.
   * @default div
   */
  swipeArea?: React.ElementType | undefined;
}

type SwipeableDrawerSlotsAndSlotProps = DrawerSlotsAndSlotProps &
  CreateSlotsAndSlotProps<
    SwipeableDrawerSlots,
    {
      /**
       * Props forwarded to the docked slot.
       * By default, the available props are based on a div element.
       */
      swipeArea: SlotProps<'div', SwipeableDrawerSwipeAreaSlotPropsOverrides, DrawerOwnerState>;
    }
  >;

export interface SwipeableDrawerProps
  extends
    Omit<DrawerProps, 'onClose' | 'open' | 'slots' | 'slotProps'>,
    SwipeableDrawerSlotsAndSlotProps {
  /**
   * If set to true, the swipe event will open the drawer even if the user begins the swipe on one of the drawer's children.
   * This can be useful in scenarios where the drawer is partially visible.
   * You can customize it further with a callback that determines which children the user can drag over to open the drawer
   * (for example, to ignore other elements that handle touch move events, like sliders).
   *
   * @param {TouchEvent} event The 'touchstart' event
   * @param {HTMLDivElement} swipeArea The swipe area element
   * @param {HTMLDivElement} paper The drawer's paper element
   *
   * @default false
   */
  allowSwipeInChildren?:
    | boolean
    | ((event: TouchEvent, swipeArea: HTMLDivElement, paper: HTMLDivElement) => boolean)
    | undefined;
  /**
   * Disable the backdrop transition.
   * This can improve the FPS on low-end devices.
   * @default false
   */
  disableBackdropTransition?: boolean | undefined;
  /**
   * If `true`, touching the screen near the edge of the drawer will not slide in the drawer a bit
   * to promote accidental discovery of the swipe gesture.
   * @default false
   */
  disableDiscovery?: boolean | undefined;
  /**
   * If `true`, swipe to open is disabled. This is useful in browsers where swiping triggers
   * navigation actions. Swipe to open is disabled on iOS browsers by default.
   * @default typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent)
   */
  disableSwipeToOpen?: boolean | undefined;
  /**
   * Affects how far the drawer must be opened/closed to change its state.
   * Specified as percent (0-1) of the width of the drawer
   * @default 0.52
   */
  hysteresis?: number | undefined;
  /**
   * Defines, from which (average) velocity on, the swipe is
   * defined as complete although hysteresis isn't reached.
   * Good threshold is between 250 - 1000 px/s
   * @default 450
   */
  minFlingVelocity?: number | undefined;
  /**
   * Callback fired when the component requests to be closed.
   *
   * @param {React.SyntheticEvent<{}>} event The event source of the callback.
   */
  onClose: React.ReactEventHandler<{}>;
  /**
   * Callback fired when the component requests to be opened.
   *
   * @param {React.SyntheticEvent<{}>} event The event source of the callback.
   */
  onOpen: React.ReactEventHandler<{}>;
  /**
   * If `true`, the component is shown.
   * @default false
   */
  open?: boolean | undefined;
  /**
   * The width of the left most (or right most) area in `px` that
   * the drawer can be swiped open from.
   * @default 20
   */
  swipeAreaWidth?: number | undefined;
}

declare const SwipeableDrawer: React.JSXElementConstructor<SwipeableDrawerProps>;
```

## Post-install acceptance

Run strict types, production build and real interactions. Check keyboard labels/focus, disabled/error/read-only semantics where natively supported, both themes, narrow screens and reduced motion. Verify callbacks against the real host data; do not declare installation complete from copying a prompt. Initialization fixtures also require server HTML and warning-free hydration.

## Source and license

https://github.com/mui/material-ui/tree/809a7717b4c050ba3f69b75300689f07c050a16e

MIT · @mui/material@9.4.0. Vendor originals and license are preserved. Full original upstream prose remains in vendor/docs and is not represented as fully translated.

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
