Skip to content

Drawer

Edge-docked panel with scrim, focus trap, and Esc-to-close. Inline-start/end aware.

View as Markdown

Preview

Static preview De-roled visual mock (no focus trap/role wired), safe to render inline.

Filters×
<div style="position:relative;height:260px;overflow:hidden;
    border:1px solid var(--nx-hairline);border-radius:14px">
  <div style="position:absolute;inset:0;
      background:var(--nx-scrim)"></div>
  <div style="position:absolute;top:0;bottom:0;right:0;width:220px;
      background:var(--nx-white);
      border-left:1px solid var(--nx-hairline);display:flex;
      flex-direction:column">
    <div class="nx-panel__head">
      <span class="nx-panel__title">Filters</span>
      <span class="nx-iconbtn">×</span>
    </div>
    <div class="nx-panel__body">
      <label class="nx-checkbox">
        <input type="checkbox" checked>
        <span class="nx-checkbox__box"></span>
        Open
      </label>
    </div>
  </div>
</div>

Variants

Open in isolation

Mounts the real, fully-correct drawer (role=dialog, focus trap, scrim-click + Esc to close).

<button class="nx-btn nx-btn--primary"
    id="openDrawerDemo">Open drawer</button>

API

React props (NxKit)

React (NxKit) props
PropTypeDefaultRequiredDescription
openbooleanRequiredControls mount.
onClose()=>voidundefinedCalled on Esc, scrim click, or the close button.
side"left"|"right""right"Docks inline-end by default; "left" now means inline-start (flips under RTL).
titleReactNodeundefinedPanel head title, wired to aria-labelledby.
footerReactNodeundefinedPanel foot content (usually actions).

Classes

Framework-agnostic classes
ClassDescription
.nx-drawerFixed edge panel, shadow-overlay
.nx-drawer--leftDocks inline-start (was literally left; now RTL-aware)
.nx-panel__head/__body/__footShared overlay chrome, also used by Modal

Accessibility

  • role="dialog" aria-modal="true"; focus moves to the first focusable (or the panel itself when it has no better target) on open, Tab/Shift+Tab wrap inside, Escape closes, and focus returns to the trigger on close (useFocusTrap).
  • Body scroll is locked while open (useBodyScrollLock) so the page behind can't scroll.

Do / Don’t

  • Do: Use for filters/secondary detail that doesn't need the user's full attention.Don't nest a drawer inside a modal or vice versa.

View in spec