# Drawer Component API A slide-out panel from any edge of the screen, similar to Sheet but with different styling. --- ## Installation ```toml # Cargo.toml [dependencies] shadcn-ui-leptos-drawer = "0.7" ``` ```rust use shadcn_ui_leptos_drawer::Drawer; ``` --- ## Import ```rust use shadcn_ui_leptos_drawer::{ Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, DrawerFooter, DrawerClose }; ``` --- ## Component API ### Drawer Root component managing drawer state. | Prop | Type | Default | Description | |------|------|---------|-------------| | `open` | `Signal` | **Required** | Open state | | `on_open_change` | `Option>` | `None` | Change handler | | `direction` | `MaybeProp` | `Right` | Slide direction | ### Direction ```rust pub enum Direction { Top, Right, Bottom, Left, } ``` --- ## Usage Examples ### Basic Drawer ```rust use leptos::prelude::*; use shadcn_ui_leptos_drawer::*; #[component] pub fn MyComponent() -> impl IntoView { let (open, set_open) = signal(false); view! { "Drawer Title"
"Drawer content"
} } ``` --- ## CSS Classes ```css .drawer-content { fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out } .drawer-content[data-direction=right] { inset-y-0 right-0 h-full w-3/4 border-l } ``` --- ## Accessibility ### Keyboard Navigation | Key | Action | |-----|--------| | **Escape** | Close drawer | --- ## TypeScript API ```typescript interface DrawerProps { open: boolean; onOpenChange?: (open: boolean) => void; direction?: 'top' | 'right' | 'bottom' | 'left'; } export const Drawer: React.FC; export const DrawerTrigger: React.FC; export const DrawerContent: React.FC; ``` --- *Source: [packages/leptos/drawer/src/default.rs](https://github.com/yourusername/leptos-shadcn-ui/blob/main/packages/leptos/drawer/src/default.rs)*