Drawer

A modal panel that slides in from an edge of the screen. Use it for secondary content that needs room but should keep the page in context, such as filters, details or mobile navigation.

  • vig-drawer
  • [vigDrawerFooter]
  • ng-template[vigDrawerContent]
Import
import { Drawer, DrawerFooter, DrawerContent } from '@vigdx/ui/drawer';

Basic

Bind [(open)] and give the drawer a heading ; position end slides it in from the end edge (the right one in left-to-right text; unset, it is the physical right edge). A vigDrawerFooter element becomes the pinned action row. Select panels inside work thanks to provideVigdxUi() , as in the dialog.

No filters

Filters

Status

Payment method

Positions

position anchors the drawer to the start , end , top or bottom edge. start and end follow the text direction: in a right-to-left layout start is the right edge. The older left and right are deprecated: they are physical edges that never swap.

Drawer at the end

Side drawers take their size from width, top and bottom drawers from height. Both are capped at 90% of the viewport.

A headerless drawer needs an ariaLabel . padding="none" (formerly [padded]="false" ) hands the body spacing to the content, e.g. a full-width navigation list. The X button stays unless closable is off; closeOnBackdropClick and closeOnEscape work as in the dialog.

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="drawer"][data-part="panel"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="drawer"]

Drawer styling hooks
Part Element data-state
panel The native <dialog> ; style the backdrop with ::backdrop . open, closed
header The header row: heading and close button. —
heading The <h2> of heading . —
close The close button ( closable ). —
body The scrolling body ( padding ). —
footer The [vigDrawerFooter] row. —
Drawer data attributes
Attribute Meaning
data-opening On the overlay element (panel or <dialog> ) while its entrance transition plays; removed once it settles (2s at most). Style the entrance with data-opening: utilities.
data-closing On the overlay element while its exit transition plays, before it closes; removed once it settles (2s at most). Style the closed look with data-closing: utilities.

Accessibility

  • Built on the native <dialog> with showModal(), like vig-dialog: the page behind is inert and Tab stays inside the drawer.
  • The drawer is named by its heading; without one, pass ariaLabel.
  • Escape, the X button (closeAriaLabel) and a backdrop click close it, each unless turned off; focus then returns to the element that opened it. A backdrop click counts only when the press and the release both land outside the drawer, so a text selection dragged out of it does not close it.
  • Scrolling over the backdrop or past the end of the drawer does not scroll the page.
  • The drawer slides in and out; when the user prefers reduced motion it fades instead.

Lazy content

Projected content is created with the vig-drawer, even while it is closed. Wrap a heavy body (a form that loads data, a chart) in <ng-template vigDrawerContent> instead: it is created when the drawer opens and destroyed once it has closed, after the exit transition.

API

Drawer

vig-drawer component

Edge-anchored modal panel (PrimeNG p-drawer/sidebar territory) on the native <dialog> element: focus trap, top-layer, Escape and focus restore come from the platform. Slides in from the chosen edge. While it plays its entrance or exit transition, the animating element carries data-opening or data-closing (stable hooks for styling and for waiting in tests; see the theming guide). data-opening data-closing

Drawer props
Name Type Default Description
ariaLabelstring | undefinedundefined
—
closablebooleantrue
—
closeAriaLabelstring | undefinedundefined
—
closeOnBackdropClickboolean | undefinedundefined

Close when the backdrop is clicked (press and release both outside the box, so dragging a text selection out never dismisses). Default true.

closeOnEscapebooleantrue

Close on Escape / the back gesture; off also disables backdrop dismissal natively.

dismissablebooleantrue

Deprecated: Use `closeOnBackdropClick`; still honored when it is unset.

—
headerstring | undefinedundefined

Deprecated: Use `heading`; still honored when `heading` is unset.

—
headingstring | undefinedundefined

Visible title, which also names the panel (aria-labelledby).

heightstring'24rem'

CSS height of top/bottom drawers, capped at 90dvh.

open model booleanfalse

Two-way: drive with a signal, e.g. [(open)]="filtersOpen".

paddedbooleantrue

Deprecated: Use `padding` (`[padded]="false"` is `padding="none"`).

—
paddingDrawerPadding | undefinedundefined

Inner spacing of the body: none lets the content own it (e.g. nav). Default md.

positionDrawerPosition'right'

Edge the drawer slides in from. The default is the physical right edge (as in 2.0, until 3.0); prefer end, which follows the text direction.

widthstring'24rem'

CSS width of side (start/end) drawers, capped at 90vw.

Templates and directives

Templates and directives
Selector Export Description
[vigDrawerFooter]DrawerFooter

Marks the footer (action row) content of a vig-drawer.

ng-template[vigDrawerContent]DrawerContent

Body content of a vig-drawer created only while it is shown: when it opens, and destroyed once it has closed (after the exit transition). Projected content, by contrast, lives as long as the vig-drawer does.

Example :
<vig-drawer [(open)]="editing" heading="Edit">
  <ng-template vigDrawerContent><app-editor /></ng-template>
</vig-drawer>

Are you sure?