Drawer
import { Drawer } from 'svogg-components';
Drawer component that traps focus internally and prevents document scroll.
Demo
Code
The creepiest animal is 🦇
Drawer
Name | Type | Required | Default | Description |
---|---|---|---|---|
open | boolean | true |
| Drawer open state |
id | (string | undefined) | false | - | HTML `id` attribute. Commonly used in conjunction with `aria-controls` on controlling element. |
width | 'auto' | 'stretch' | false | 'auto' | Fit to content or stretch across screen. Does nothing if position is `top` or `bottom`. |
duration | number | false | 200 | In/out transition duration |
position | 'top' | 'bottom' | 'left' | 'right' | false | 'right' | Drawer starting position |
role | string | false | 'complementary' | HTML `aria-role` attribute |
as | string | false | 'div' | HTML tag |
CSS
Class | Description |
---|---|
.svogg-drawer-overlay | Applied to overlay |
.svogg-drawer | Applied to drawer container |
Keyboard navigation
- Tab
- Moves focus to next focusable child element.
- If the last focusable element has focus, moves focus to the first focusable child element.
- Shift + Tab
- Moves focus to previous focusable child element.
- If the first focusable element has focus, moves focus to the last focusable child element.
- Esc
- Closes the drawer.