Live demo
Demo source
Use a drawer for details or a secondary task, such as settings or a longer form, when people should keep the page in view. For a short decision that must interrupt the flow, use a dialog. While a drawer is open, the page behind it is covered and can't be used.
Dialog or drawer
Choose a dialog for an immediate decision and a drawer for contextual details,
settings or a longer sequence of steps. The design also describes drawers
without an overlay. This implementation always uses a modal overlay: the
underlying page remains visible but is not interactive. There is no
showOverlay property.
Anatomy
A drawer on the right of a dimmed overlay, with a title, subtitle, message, and Cancel and Apply actions. Callouts mark 1 the header, 2 the body, 3 the footer, 4 the close button and 5 the overlay.
- Header (
nv-drawerheader): a title and an optional subheading. - Body: the default slot. It scrolls when the content is long.
- Footer (
nv-drawerfooter): a cancel and a primary action. - Close button: removed with
undismissable, which also turns off Escape. - Overlay: closes the drawer when clicked only with
clickOutside.
Sizes
| Size | Typical content |
|---|---|
sm | A few details or a short settings task. |
md | A form or a moderate amount of contextual information. |
lg | A complex layout or several related steps. |
full | A task needing the available viewport width. |
size controls width for the implemented left and right drawers. The design
mentions horizontal drawers where supported; top and bottom drawers are not
available in this component. Use width for an application-specific width.
Look and feel
Spark and Ocean style the same header, scrollable body, footer and overlay. Keep the side panel visually connected to the page it supplements.
Customising the sections
The header slot accepts a title, icons or contextual controls, and the
footer slot accepts custom actions or step navigation. Body content goes
in the default slot, not a named body slot. Design the body for flexible
height and scrolling; keep its main actions in the footer so long content
does not push them out of reach.
Placement and closing
side puts the drawer on the left or right (the default), and size sets
its width: sm, md (the default), lg or full. A button in the
trigger slot opens the drawer; with controlled, your application opens it
through open. Escape and the close button update open. A slotted
nv-drawerfooter emits drawerCanceled: an uncontrolled, dismissible drawer
then closes itself. A controlled drawer stays open until your handler changes
open. The primary action emits drawerPrimaryClicked and never closes the
drawer automatically.
The design's dismissible option maps to the inverse of undismissable. If you
remove the close button, provide a clear way to complete the task. Preserve the
drawer's accessible title when supplying a custom header; autofocus is an
optional way to focus the first control on opening.