--- title: "Drawer" slug: drawer category: component type: documentation version: 20.0.0 tokens: 1714 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-drawer--documentation.txt --- # Drawer The Drawer component provides a sliding panel that reveals additional content without navigating away from the current page. ## Overview | | | |---|---| | Name | Drawer | | Also known as | Sidenav, Panel | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/branch/5BA2ZwZaX2bzfiWwTyMpQH/ODS---UI-Kit?node-id=5488-15121&p=f&t=gPfKLQM0iEuF2FXm-0 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/drawer | ## Usage The **Drawer** component is ideal for use cases where content should be revealed in context without navigating to a new page. Common examples include: - Side navigation menus - Filters and settings panels - Detail views or contextual information **Do** - Use a Drawer to display contextual content or actions that stay relevant to the current page (e.g., filters, side forms, settings) - Allow the Drawer to be dismissed via clear and accessible interactions (e.g., close button, escape key, clicking outside, when enabled) - Customize the Drawer's width, height, and placement to match your layout and content needs - Keep transitions smooth and responsive, respecting the expected animation duration (e.g., 300ms) in the OVHcloud Design System - Maintain proper layering and z-index behavior - Use Drawers to maintain continuity of the user's workflow without breaking the page context **Don't** - Don't add more than one open Drawer at a time - Don't use excessively large Drawers that cover most or all of the page - Don't rely on Drawers for critical actions that require user confirmation, Modals are better suited for that - Don't leave Drawers open without a visible way to close them, always provide a clear exit path ### Best Practices in Context 1. **Drawer** ## Placement The **Drawer** can be positioned on any edge of the screen: - **Left/Right**: Covers 100% of the page height, with a default width of 320px and a maximum width of 100% - 3rem (48px) - **Top/Bottom**: Covers 100% of the page width, with a default height of 320px and a maximum height of 100vh - 3rem (48px) The **Drawer** is displayed above all page content but is positioned below the Modal in terms of layering, with or without backdrop, following the z-index hierarchy defined by OVHcloud Design System. This ensures consistent stacking behavior across components. By default, the OVHcloud Design System does not enforce whether the **Drawer** is fixed or scrollable. Integrators can configure this behavior based on their specific use case and requirements. Be careful the placement of the drawer can be broken if you create a new [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_positioned_layout/Understanding_z-index/Stacking_context). For example with a transform style or scale. ## Behavior The **Drawer** supports the following interactions: - Expansion: Triggered by interacting with a designated element, such as a button. - Collapsing: - By interacting with the same trigger used for expansion - By pressing the escape key - By clicking or moving the focus outside the Drawer (or clicking its backdrop), when `closeOnInteractOutside` is enabled (default with a backdrop) Animation: The **Drawer** slides into view with a smooth animation (default duration: 300ms). ## Backdrop The **Drawer** can display a backdrop behind it, using the same style as the Modal backdrop. Use it when the Drawer content requires the user's full attention and the rest of the page should not be used in the meantime (e.g., a side form to complete before going back to the page). Without backdrop, the page stays fully interactive, which suits contextual content such as filters or detail views. With a backdrop, the **Drawer** behaves as a modal: - Focus is trapped inside the Drawer - The rest of the page is inert and cannot be scrolled - Clicking on the backdrop closes the Drawer, unless `closeOnInteractOutside` is set to `false` ```tsx My drawer content ``` ## Variation The **Drawer** can slide in from the left, right, top, or bottom, depending on its configuration and the layout of the page. ## Navigation ### Focus Management When the **Drawer** is opened, focus automatically moves to the first focusable element inside. When the **Drawer** is closed while focus is inside it, or after its focused element was removed, focus returns to the trigger it was opened from, or, for a Drawer without trigger, to the element that was focused before it opened. A focus moved elsewhere in the page is left where it is. ### General Keyboard Shortcuts Pressing `Escape` closes the **Drawer**. Pressing `Tab` moves focus forward through the focusable elements inside the **Drawer**. Pressing `Shift` + `Tab` moves focus backward within the **Drawer**. With a backdrop, once the last focusable element is reached, focus does not leave the **Drawer** unless it is closed. Without backdrop, focus is not trapped and can leave the **Drawer** (e.g. with `Shift` + `Tab` from its first element), which then closes if `closeOnInteractOutside` is enabled. ## Accessibility To ensure the **Drawer** is fully accessible, correct ARIA attributes must be implemented. This ensures screen readers announce the **Drawer** properly and that keyboard users can interact with it effectively. ### Linking the Drawer title and content Ensure that assistive technologies announce the **Drawer** correctly using [aria-labelledby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby) or [aria-label](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label), and [aria-describedby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-describedby). ```tsx The drawer content ``` ```tsx

My drawer

The drawer content

``` Screen readers will announce the sections referenced by the aria attributes.