Nested Drawers
Svelte Drawer supports nested drawers, allowing you to open one drawer from within another. This is useful for multi-step workflows, detail views, and progressive disclosure patterns.What This Example Shows
- Opening a drawer from within another drawer
- Independent state management for each drawer
- Portal rendering to avoid z-index conflicts
- Proper focus management with nested content
Code Example
Best Practices
1. Use Portal Rendering
Always enable portal for nested drawers to avoid z-index issues:2. Increase Overlay Opacity
Make the nested drawer’s overlay darker to indicate hierarchy:3. Different Directions
Consider using different directions for visual hierarchy:Advanced Example: Side + Bottom Drawers
Common Use Cases
Multi-Step Forms
- Main drawer shows form overview
- Nested drawer for detailed field configuration
- Another nested drawer for help/documentation
E-Commerce
- Product list in main drawer
- Product details in nested drawer
- Size guide in third drawer
Navigation + Details
- Sidebar for navigation menu
- Bottom sheet for selected item details
- Full-screen drawer for editing
Focus Management
Focus is automatically managed between nested drawers:- Opening a nested drawer moves focus to it
- Closing the nested drawer returns focus to the parent
- Escape key closes the topmost drawer first
- Each drawer maintains its own focus trap
Performance Tips
- Use portal: Always enable for nested drawers
- Lazy load: Don’t render nested drawer content until needed
- Limit nesting: Avoid more than 2-3 levels deep
- Close on navigation: Close parent drawers when opening nested ones if appropriate