We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Drawer Component

The Drawer component creates a mobile-optimized bottom sheet that slides up from the screen’s bottom edge. It provides a native-feeling experience with smooth animations, gesture controls, and accessibility features built-in.

  • Check Circle

    Intuitive: Natural touch gestures and smooth animations

  • Check Circle

    Responsive: Optimized for mobile and desktop interactions

  • Check Circle

    Accessible: Keyboard navigation and screen reader support

  • Check Circle

    Flexible: Customizable content and styling options

<Button id="drawer-trigger">Open Settings</Button>
<Drawer triggerQuery="#drawer-trigger">
<h2 class="text-xl font-bold">Settings</h2>
<p>Configure your preferences here.</p>
</Drawer>

Try the interactive example:

Interactive Demo

Explore the drawer’s features:

  • Check Circle

    Drag handle for intuitive dismissal

  • Check Circle

    Smooth animations

  • Check Circle

    Backdrop overlay

  • Check Circle

    Multiple dismiss methods

  1. Touch Gestures

    • Drag to dismiss
    • Velocity-based animations
    • Natural-feeling physics
  2. Click Actions

    • Trigger button to open
    • Close button to dismiss
    • Backdrop tap to close
  3. Keyboard Support

    • Escape key dismissal
    • Focus trap navigation
    • ARIA attribute integration
Drawer Component Props Extends <div> HTMLElement
Prop Type Default Description
triggerQuery string CSS selector for trigger element
closeText string Close Custom close button text
closeButtonProps ButtonProps {} Props for close button

The drawer component provides a set of functions to interact with the drawer:

Drawer Component Functions
Function Type Description
toggle (force?: boolean) => void Toggles the drawer, optionally force open or closed

The component emits custom events for changes:

document.querySelector('drawer-wrapper').addEventListener(DrawerEventNames.Open, (event) => {
// Handle open
});
document.querySelector('drawer-wrapper').addEventListener(DrawerEventNames.Close, (event) => {
// Handle close
});
Settings panels
Filter interfaces
Action menus
Detail views
Share sheets
Selection pickers

Limited Time Launch Sale

Create engaging mobile experiences with our pre-built Drawer component. Get started with our AstroJS template today.

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes