Create

Feedback

Drawer

Copy page View as Markdown Open in ChatGPT Open in Claude

A panel that slides in from an edge of the screen.

Usage#

app.component.ts
import { WdsDrawerComponent } from '@wds/angular/drawer';

Examples#

Default#

show() and close() open and close the drawer; heading and description name and describe it. With handle, drag the handle or the header toward the edge (or flick it) to close. Buttons in the footer slot are stacked.

Open drawer

Drag the handle or the header down to close the drawer.

SubmitCancel

Position#

placement sets the edge: top, right, bottom (default) or left.

toprightbottomleft

Close it with Escape, a click on the backdrop or the button.

Close

Size#

--wds-drawer-size sets the width of a left or right drawer, or the height of a top or bottom one.

Small (20rem)Large (40rem)

Drawer content.

Drawer content.

Nested#

A drawer can open another one on top; Escape and the backdrop close only the top drawer.

Open drawerOpen nested drawerBack

Non-modal#

modal set to false (a property) opens the drawer without a backdrop: the page stays usable and focus is not trapped.

Open drawerClicked 0×
Close

Snap points#

snapPoints lets a top or bottom drawer stop at several heights (fractions of the screen, pixels or strings such as 320px). Dragging moves between them and fires wds-snap-change; snapPoint sets the active one.

Open drawerSnap point: 0.3

Row 1

Row 2

Row 3

Row 4

Row 5

Row 6

Row 7

Row 8

Row 9

Row 10

Row 11

Row 12

Row 13

Row 14

Row 15

Row 16

Row 17

Row 18

Row 19

Row 20

Row 21

Row 22

Row 23

Row 24

Row 25

Row 26

Row 27

Row 28

Row 29

Row 30

Responsive#

A dialog on wide screens and a drawer from the bottom on narrow ones, chosen with matchMedia.

Edit profile

Make changes to your profile here.

Save changes

Make changes to your profile here.

Save changesCancel

Service#

In Angular, WdsDrawerService.open() creates the drawer from a component: data goes to the component through WDS_OVERLAY_DATA, okText / cancelText add footer buttons, and the value returned by onOk comes out of closed. HTML and React have no service, so their tabs show the same drawer declared in the markup.

Set goalGoal: 350 calories/day

API References#

wds-drawer#

A panel that slides in from an edge of the screen. Closed with Escape, a click on the backdrop, or by dragging the handle or the header. Top and bottom drawers support snap points (snapPoints).

Attributes

AttributeTypeDefaultDescription
placementWdsDrawerPlacement'bottom'Edge of the screen.
handlebooleanfalseShows the drag handle.
modalbooleantruefalse: no backdrop and no page lock (the page stays usable). Set it as a property.
openbooleanfalseControls visibility. Also set by show() and close().
headingstring''Title (or the heading slot).
descriptionstring''Description under the title (or the description slot), linked as aria-describedby.
hide-close.hideClosebooleanfalseHides the close button in the header.
static-backdrop.staticBackdropbooleanfalseA click on the backdrop does not close it.
dismissiblebooleantruefalse blocks closing with Escape, the backdrop (and dragging in a drawer).
close-label.closeLabelstring'Zamknij'Label of the close button.

Properties

PropertyDescription
snapPointsWdsDrawerSnapPoint[]Snap points (top/bottom only), e.g. [0.4, 1] or ['200px', 0.8].
snapPointWdsDrawerSnapPoint | undefinedThe active snap point (default the first of snapPoints).

Events

EventDescription
wds-snap-changeCustomEvent<WdsDrawerSnapChangeDetail>The snap point changes by dragging.
wds-closeCustomEvent<void>Closing (button, Escape, backdrop, close()), before the exit animation.
wds-after-closeCustomEvent<void>After the exit animation.

Methods

MethodDescription
show()Opens it.
close()Closes it.

Slots

SlotDescription
(default)Content. An element with autofocus gets focus when it opens (otherwise the first focusable element).
headingCustom heading (instead of the heading attribute).
descriptionCustom description (instead of the description attribute).
footerActions (stacked in a column).

CSS parts (::part)

PartDescription
dialogThe native <dialog> (the panel).
panelThe content container.
handleThe drag handle.
headerThe header.
titleThe title.
descriptionThe description.
closeThe close button.
bodyThe content.
footerThe footer.

CSS custom properties

PropertyDescription
--wds-drawer-sizeWidth (left/right, default min(75vw, 24rem)) or height (top/bottom).
--wds-drawer-backdropColor of the backdrop.

Accessibility#

Screen reader#

The drawer is a native <dialog> named by heading and described by description (aria-labelledby, aria-describedby). Always give it a heading; hide it visually if the design has no title.

A modal drawer (default) makes the rest of the page inert and keeps focus inside; when it closes, focus returns to the element that opened it.

The close button is named by close-label (default Zamknij, in Polish). The drag handle is decorative and hidden from screen readers.

Dragging needs a pointer. With hide-close, keep another way to close the drawer, such as a button in the footer; Escape also works in a modal drawer.

Keyboard support#

KeyFunction
TabShift + TabMoves focus between the controls of the drawer; in a modal drawer focus stays inside.
EscapeCloses the modal drawer (unless dismissible is false). A nested drawer closes first.
Footer