Overview
TheDrawerHeader component provides a pre-styled header for drawers with optional title, description, and close button. It’s entirely optional—you can build custom headers using regular HTML instead.
Props
Header title text. Rendered as an
<h2> with semibold styling.Optional description text displayed below the title. Rendered as a
<p> with gray color.Whether to display a close button (X icon) in the top-right corner.
Custom close handler. If not provided, uses the drawer’s default
closeDrawer() function from context.Additional CSS classes to customize the header styling.
Usage Examples
Basic Header
Header with Close Button
Custom Close Handler
Custom Header Content
You can pass custom content as children instead of usingtitle and description props:
Styled Header
With DrawerHandle
Complete Layout Example
Default Styling
The header includes:border-b border-gray-200- Bottom border separatorp-4- Padding on all sides- Title:
text-lg font-semibold text-gray-900 - Description:
text-sm text-gray-600 mt-1 - Close button: Rounded with hover effect
Close Button Icon
The close button uses an SVG X icon:- Size:
w-5 h-5 - Color:
text-gray-500 - Interactive area:
p-2withrounded-md - Hover:
hover:bg-gray-100 - Accessible:
aria-label="Close drawer"
Accessibility
The component includes:- Semantic
<h2>for title (proper heading hierarchy) <p>for descriptionaria-label="Close drawer"on close button- Keyboard accessible close button
- Works with screen readers
When to Use
UseDrawerHeader when:
- You want a quick, consistent header without custom styling
- You need a title and/or description
- You want a built-in close button
- You need complex layouts (tabs, icons, buttons)
- You want full control over styling
- You’re using a design system with custom header patterns
Alternative: Custom Header
You can build headers without this component:Related Components
- DrawerFooter - Optional footer component
- DrawerContent - Content container
- DrawerHandle - Visual drag indicator
- Drawer - Main wrapper component