--- title: Drawer description: "`Drawer` is a component for a panel that appears from the edge of the screen." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/drawer/drawer.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/drawer - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-drawer--basic --- ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ## Usage ```tsx import { Drawer } from "@yamada-ui/react" ``` ```tsx import { Drawer } from "@/components/ui" ``` ```tsx import { Drawer } from "@workspaces/ui" ``` ```tsx ``` :::note `Drawer.Overlay` and `Drawer.CloseButton` can be omitted. ::: ### Change Size ```tsx {(size) => ( ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 )} ``` ### Change Position To change the display position, set `placement` to values like `"block-start"` or `"inline-start"`. By default, `"inline-end"` is set. ```tsx {(placement) => ( ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 )} ``` ### Change Duration To change the duration, set `duration` to a numerical value (seconds). ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ### Do Not Block Scroll on Mount By default, scrolling of the main content is blocked when the panel is opened to ensure accessibility. If you do not want to block the scroll of the main content, set `blockScrollOnMount` to `false`. ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ### Disable the Close Button To disable the close button, set `withCloseButton` to `false`. ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ### Disable the Overlay To disable (hide) the overlay of the panel, set `withOverlay` to `false`. ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ### Close on drag If you want to close the `Drawer` on drag, set `closeOnDrag` to `true`. ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ### Hide the Drag Bar To hide the drag bar, set `withDragBar` to `false`. ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ### Customize the Close Button ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ### Customize the Overlay ```tsx ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ``` ### Control Use `open` and `onClose` to control the visibility. ```tsx const { open, onOpen, onClose } = useDisclosure() return ( <> ドラゴンボール 『ドラゴンボール』は、鳥山明による日本の漫画作品です。『週刊少年ジャンプ』(集英社)にて1984年51号から1995年25号まで連載された。世界中に散らばった七つの球をすべて集めると、どんな願いも一つだけ叶えられるという秘宝・ドラゴンボールと、主人公・孫悟空(そん・ごくう)を中心に展開する、「冒険」「夢」「バトル」「友情」などを描いた長編漫画。 ) ``` ## Props ### Drawer.Root | Prop | Default | Type | Description | | ----------------------- | -------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `size` | `"lg"` | `"2xl" \| "3xl" \| "4xl" \| "5xl" \| "6xl" \| "full" \| "lg" \| "md" \| "sm" \| "xl" ...` | The size of the component. | | `allowPinchZoom` | `false.` | `boolean` | Handle zoom or pinch gestures on iOS devices when scroll locking is enabled. | | `blockScrollOnMount` | `true` | `boolean` | If `true`, scrolling will be disabled on the `body` when the drawer opens. | | `body` | - | `DrawerBodyProps \| ReactNode` | The drawer body to use. | | `cancel` | - | `ButtonProps \| ReactNode` | The drawer cancel button to use. | | `closeOnDrag` | `false` | `boolean` | If `true`, then the drawer will close on drag. | | `closeOnEsc` | `true` | `boolean` | If `true`, the modal will close when the `Esc` key is pressed. | | `closeOnOverlay` | `true` | `boolean` | If `true`, the modal will close when the overlay is clicked. | | `defaultOpen` | - | `boolean` | If `true`, the element will be initially opened. | | `dragConstraints` | `0` | `number` | Applies constraints on the permitted draggable area. | | `dragElastic` | `0.1` | `number` | The degree of movement allowed outside constraints. 0 = no movement, 1 = full movement. | | `dragOffset` | `80` | `number` | Offset from being dragged to closing. | | `dragVelocity` | `100` | `number` | Velocity of the drag that triggers close. | | `duration` | - | `MotionTransitionProps["duration"]` | The animation duration. | | `finalFocusRef` | - | `RefObject` | `ref` of the element to return focus to when `FocusLock` unmounts. | | `footer` | - | `DrawerFooterProps \| ReactNode` | The drawer footer to use. | | `header` | - | `DrawerHeaderProps \| ReactNode` | The drawer header to use. | | `initialFocusRef` | - | `RefObject` | `ref` of the element to receive focus initially. | | `lockFocusAcrossFrames` | `false` | `boolean` | Enables aggressive focus capturing within iframes. - If `true`: keep focus in the lock, no matter where lock is active. - If `false`: allows focus to move outside of iframe. | | `middle` | - | `ButtonProps \| ReactNode` | The drawer middle button to use. | | `onCancel` | - | `(onClose: () => void) => void` | The callback invoked when cancel button clicked. | | `onClose` | - | `() => void \| Promise` | Callback invoked to close the element. | | `onCloseComplete` | - | `() => void` | Callback function to run side effects after the drawer has closed. | | `onEsc` | - | `() => void` | Callback invoked when the escape key is pressed and focus is within modal. | | `onMiddle` | - | `(onClose: () => void) => void` | The callback invoked when middle button clicked. | | `onOpen` | - | `() => void \| Promise` | Callback invoked to open the element. | | `onSuccess` | - | `(onClose: () => void) => void` | The callback invoked when success button clicked. | | `open` | - | `boolean` | If `true`, the element will be opened. | | `placement` | `"inline-end"` | `"block-end" \| "block-start" \| "inline-end" \| "inline-start" ...` | The placement of the drawer. | | `portalProps` | - | `Omit` | Props to be forwarded to the portal component. | | `restoreFocus` | `false` | `boolean` | If `true`, focus will be restored to the element that triggered the `FocusLock` once it unmounts. | | `success` | - | `ButtonProps \| ReactNode` | The drawer success button to use. | | `title` | - | `DrawerTitleProps \| ReactNode` | The drawer title to use. | | `trigger` | - | `ReactNode` | The modal trigger to use. | | `withCloseButton` | `true` | `boolean` | If `true`, display the drawer close button. | | `withDragBar` | `true` | `boolean` | If `true`, display the drag bar when `closeOnDrag` is `true`. | | `withOverlay` | `true` | `boolean` | If `true`, display the drawer overlay. | ### Drawer.CloseButton | Prop | Default | Type | Description | | --------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | - | `"2xl" \| "2xs" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. | | `variant` | - | `"ghost" \| "outline" \| "solid" \| "subtle" \| "surface" ...` | The variant of the component. | | `active` | `false` | `boolean` | If `true`, the button is represented as active. | | `disabled` | `false` | `boolean` | If `true`, the button is disabled. | | `disableRipple` | `false` | `boolean` | If `true`, disable ripple effects when pressing a element. | | `fullRounded` | `false` | `boolean` | If `true`, the button is full rounded. Else, it'll be slightly round. | | `icon` | - | `string \| number \| bigint \| boolean \| ReactElement> \| Iterable \| ReactPortal \| Promise<...>` | The icon to be used in the button. | | `loading` | `false` | `boolean` | If `true`, the loading state of the button is represented. | | `type` | `"button"` | `"button" \| "reset" \| "submit"` | The type of button. Accepts `button`, `reset`, or `submit`. | ### Drawer.CloseTrigger | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ### Drawer.Content | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `keyof IntrinsicElements` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ### Drawer.DragBar | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ### Drawer.Footer | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ### Drawer.Header | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ### Drawer.OpenTrigger | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ### Drawer.Overlay | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `DOMElement` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ### Drawer.Title | Prop | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | ## Accessibility Currently, this section is being updated due to the migration of v2.