Skip to main content
cngx-src documentation

CngxDrawerPanel

Directivev0.1.0WCAG AA

projects/common/layout/drawer/drawer-panel.directive.ts

Import#

import { CngxDrawerPanel } from '@cngx/common/layout'

Description#

The sliding panel of a drawer. Reads its open state from an explicit [cngxDrawerPanel] reference - no ancestor injection.

Composes CngxFocusTrap as a hostDirective - the consumer controls the [enabled] and [autoFocus] inputs from the template.

Optionally closes the drawer when the user clicks outside the panel (closeOnClickOutside, default true).

<nav [cngxDrawerPanel]="drawer" position="left" mode="over"
     [enabled]="drawer.opened()" [autoFocus]="true">
  <a href="/home">Home</a>
</nav>

https://cngxjs.github.io/cngx/examples/#/common/layout/drawer/basic-scroll-lock-backdrop https://cngxjs.github.io/cngx/examples/#/common/layout/drawer/controlled-mode https://cngxjs.github.io/cngx/examples/#/common/layout/drawer/direction-all-four-sides https://cngxjs.github.io/cngx/examples/#/common/layout/drawer/events-openedchange-closed https://cngxjs.github.io/cngx/examples/#/common/layout/drawer/mode-over-push-side https://cngxjs.github.io/cngx/examples/#/common/layout/drawer/pattern-consumer-wiring

Metadata#

Host#

Index#

Inputs#

closeOnClickOutside#boolean
input()

Whether clicking outside the panel closes the drawer.

default true
drawerRef#CngxDrawer
input()Required

Reference to the parent CngxDrawer state owner.

default { alias: 'cngxDrawerPanel' }
input()

How the panel interacts with the content area:

  • 'over' (default) - overlays content (absolute positioned)
  • 'push' - pushes content aside (content gets margin)
  • 'side' - always visible, no toggle behavior
default 'over'
input()

Direction the panel slides from.

default 'left'

HostBindings#

BindingExpression
[class.cngx-drawer-panel]true
[class.cngx-drawer-panel--open]isOpen()
[class.cngx-drawer-panel--left]position() === 'left'
[class.cngx-drawer-panel--right]position() === 'right'
[class.cngx-drawer-panel--top]position() === 'top'
[class.cngx-drawer-panel--bottom]position() === 'bottom'
[class.cngx-drawer-panel--over]mode() === 'over'
[class.cngx-drawer-panel--push]mode() === 'push'
[class.cngx-drawer-panel--side]mode() === 'side'
[attr.aria-hidden]mode() === 'side' ? null : !isOpen()