--- title: Drawer sidebar desc: Drawer is a grid layout that can show/hide a sidebar on the left or right side of the page. source: https://raw.githubusercontent.com/saadeghi/daisyui/refs/heads/master/packages/daisyui/src/components/drawer.css layout: components classnames: component: - class: drawer desc: The wrapper for sidebar and content part: - class: drawer-toggle desc: The hidden checkbox that controls the state of drawer - class: drawer-content desc: Content part - class: drawer-side desc: Sidebar part - class: drawer-overlay desc: Label that covers the page when drawer is open placement: - class: drawer-end desc: puts drawer to the other side modifier: - class: drawer-open desc: Forces the drawer to be open variant: - class: "is-drawer-open:" desc: Applies styles when the drawer is open - class: "is-drawer-close:" desc: Applies styles when the drawer is closed --- ### Structure Drawer is a grid layout that can show/hide a sidebar on the left or right side of the page, based on the screen size or based on the value of a `drawer-toggle` checkbox. Drawer must be the parent element of the content and sidebar. ```json:Structure .drawer // The root container ├── .drawer-toggle // A hidden checkbox to toggle the visibility of the sidebar ├── .drawer-content // All your page content goes here │ ╰── // navbar, content, footer │ ╰── .drawer-side // Sidebar wrapper ├── .drawer-overlay // A dark overlay that covers the whole page when the drawer is open ╰── // Sidebar content (menu or anything) ``` ### Functionality Drawer sidebar is hidden by default. You can make it visible on larger screens using `lg:drawer-open` class (or using other responsive prefixes: sm, md, lg, xl) You can check/uncheck the checkbox using JavaScript or by clicking the `label` tag which is assigned to the hidden checkbox > :INFO: > > Opening a drawer adds a [scrollbar-gutter](https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-gutter) to the page to avoid layout shift on operating systems that have a fixed scrollbar. > On recent Chromium based browsers vertical scrollbar presence is detected automatically. On Safari and on mobile devices the scrollbar is displayed as overlay so there will not be gutter. On Firefox you need to detect the presence of vertical scrollbar and set the `scrollbar-gutter: stable` or `scrollbar-gutter: unset` on `:root` element yourself. > If you don't want to use this feature, [you can exclude `rootscrollgutter`](/docs/config/#exclude). ### ~Drawer sidebar