svogg-components 0.5.4

Drawer

typescript
import { Drawer } from 'svogg-components';

Drawer component that traps focus internally and prevents document scroll.

The creepiest animal is 🦇

Drawer

Props
NameTypeRequiredDefaultDescription
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

ClassDescription
.svogg-drawer-overlay Applied to overlay
.svogg-drawer Applied to drawer container

Keyboard navigation

  1. Tab
    1. Moves focus to next focusable child element.
    2. If the last focusable element has focus, moves focus to the first focusable child element.
  2. Shift + Tab
    1. Moves focus to previous focusable child element.
    2. If the first focusable element has focus, moves focus to the last focusable child element.
  3. Esc
    1. Closes the drawer.