Overview
TheDrawerOverlay component renders a semi-transparent backdrop behind the drawer. Clicking the overlay closes the drawer. It supports optional backdrop blur effects for a premium visual appearance.
Props
CSS classes for styling the overlay. Typically includes positioning (
fixed inset-0) and background color.Enable backdrop blur effect for a modern, premium look. Pass
true for medium blur, or specify intensity.Blur Options
Theblur prop accepts the following values:
false- No blur (default)trueor"md"- Medium blur (backdrop-blur-md)"sm"- Small blur (backdrop-blur-sm)"lg"- Large blur (backdrop-blur-lg)"xl"- Extra large blur (backdrop-blur-xl)"2xl"- 2x extra large blur (backdrop-blur-2xl)"3xl"- 3x extra large blur (backdrop-blur-3xl)
Usage Examples
Basic Overlay
With Backdrop Blur
Custom Blur Intensity
Different Background Colors
Behavior
The overlay component:- Appears when drawer opens: Fades in with opacity animation
- Closes on click: Clicking anywhere on the overlay closes the drawer
- Keyboard accessible: Pressing Enter or Space while focused closes the drawer
- Auto-positioned: Uses
z-index: 40(below drawer content at z-index: 50)
Accessibility
The component includes:role="button"- Indicates the overlay is clickabletabindex="0"- Makes the overlay keyboard-focusablearia-label="Close drawer"- Provides accessible label- Keyboard handlers for Enter and Space keys
Styling
The component automatically applies:fixed inset-0- Covers entire viewport (must be inclassprop)z-index: 40- Positioned below drawer contentcursor: pointer- Indicates clickability- Dynamic opacity based on drawer state
- Conditional backdrop blur classes
Opacity Recommendations
Without blur:Performance
Backdrop blur can be GPU-intensive on lower-end devices. Consider:- Using
blur="sm"orblur="md"for better performance - Testing on target devices before using
blur="2xl"orblur="3xl" - Providing a fallback without blur for older browsers
Browser Support
Backdrop blur (backdrop-filter) is supported in:
- Chrome/Edge 76+
- Firefox 103+
- Safari 9+ (with
-webkit-prefix, handled by Tailwind) - Opera 63+
Related Components
- Drawer - Main wrapper component
- DrawerContent - Content container
- DrawerPortal - Portal rendering