Drawer

A dialog that slides in from the bottom of the screen. Designed after the macOS/iOS bottom sheet pattern.

Installation

ng g @spartan-ng/cli:ui drawer

Usage

import { HlmDrawerImports } from '@spartan-ng/helm/drawer';
<hlm-drawer>
  <button hlmDrawerTrigger hlmBtn variant="outline">Open</button>
  <hlm-drawer-content *hlmDrawerPortal="let ctx">
    <hlm-drawer-header>
      <h3 hlmDrawerTitle>Are you absolutely sure?</h3>
      <p hlmDrawerDescription>This action cannot be undone.</p>
    </hlm-drawer-header>
  </hlm-drawer-content>
</hlm-drawer>

Examples

Direction

You can change the direction the drawer slides in from using the direction input on the trigger.

Nested

Drawers can be nested within each other to create multi-step or drill-down experiences. Use a nested hlm-drawer inside the content of another drawer.

RTL

To enable RTL support in spartan-ng, see the RTL configuration guide.

Brain API

BrnDrawerClose

Selector: button[brnDrawerClose]

BrnDrawerContent

Selector: [brnDrawerContent]

Inputs

PropTypeDefaultDescription
class string | null | undefined undefined -
context T | undefined undefined -

BrnDrawerDescription

Selector: [brnDrawerDescription]

BrnDrawerHandle

Selector: [brnDrawerHandle]

Inputs

PropTypeDefaultDescription
closeThreshold number DEFAULT_CLOSE_THRESHOLD -

BrnDrawerOverlay

Selector: [brnDrawerOverlay],brn-drawer-overlay

Inputs

PropTypeDefaultDescription
class string | null | undefined undefined -

BrnDrawerTitle

Selector: [brnDrawerTitle]

BrnDrawerTrigger

Selector: button[brnDrawerTrigger]

Inputs

PropTypeDefaultDescription
direction 'bottom' | 'top' | 'left' | 'right' | undefined undefined -
id string `brn-dialog-trigger-${++triggerIdSequence}` -
type 'button' | 'submit' | 'reset' 'button' -
brnDialogTriggerFor BrnDialog | undefined undefined -

BrnDrawer

Selector: [brnDrawer],brn-drawer

ExportAs: brnDrawer

Inputs

PropTypeDefaultDescription
direction 'bottom' | 'top' | 'left' | 'right' 'bottom' -
id string `brn-dialog-${++dialogIdSequence}` -
state BrnDialogState | null null -
role BrnDialogOptions['role'] this._defaultOptions.role -
hasBackdrop boolean this._defaultOptions.hasBackdrop -
positionStrategy BrnDialogOptions['positionStrategy'] this._defaultOptions.positionStrategy -
scrollStrategy BrnDialogOptions['scrollStrategy'] | 'close' | 'reposition' | null this._defaultOptions.scrollStrategy -
restoreFocus BrnDialogOptions['restoreFocus'] this._defaultOptions.restoreFocus -
closeOnOutsidePointerEvents boolean this._defaultOptions.closeOnOutsidePointerEvents -
attachTo BrnDialogOptions['attachTo'] this._defaultOptions.attachTo -
attachPositions BrnDialogOptions['attachPositions'] this._defaultOptions.attachPositions -
autoFocus BrnDialogOptions['autoFocus'] this._defaultOptions.autoFocus -
disableClose boolean this._defaultOptions.disableClose -
aria-describedby BrnDialogOptions['ariaDescribedBy'] this._defaultOptions.ariaDescribedBy -
aria-labelledby BrnDialogOptions['ariaLabelledBy'] this._defaultOptions.ariaLabelledBy -
aria-label BrnDialogOptions['ariaLabel'] this._defaultOptions.ariaLabel -
aria-modal boolean this._defaultOptions.ariaModal -

Outputs

PropTypeDefaultDescription
closed TResult --
stateChanged BrnDialogState --

Helm API

HlmDrawerClose

Selector: button[hlmDrawerClose]

HlmDrawerContent

Selector: hlm-drawer-content

Inputs

PropTypeDefaultDescription
closeThreshold number DEFAULT_CLOSE_THRESHOLD -

HlmDrawerDescription

Selector: [hlmDrawerDescription]

HlmDrawerFooter

Selector: [hlmDrawerFooter],hlm-drawer-footer

HlmDrawerHeader

Selector: [hlmDrawerHeader],hlm-drawer-header

HlmDrawerOverlay

Selector: [hlmDrawerOverlay],hlm-drawer-overlay

Inputs

PropTypeDefaultDescription
class ClassValue '' -

HlmDrawerPortal

Selector: [hlmDrawerPortal]

Inputs

PropTypeDefaultDescription
context T | undefined undefined -
class string | null | undefined undefined -

HlmDrawerTitle

Selector: [hlmDrawerTitle]

HlmDrawerTrigger

Selector: button[hlmDrawerTrigger]

Inputs

PropTypeDefaultDescription
id string `brn-dialog-trigger-${++triggerIdSequence}` -
direction 'bottom' | 'top' | 'left' | 'right' | undefined undefined -
type 'button' | 'submit' | 'reset' 'button' -

HlmDrawer

Selector: hlm-drawer

ExportAs: hlmDrawer

Inputs

PropTypeDefaultDescription
direction 'bottom' | 'top' | 'left' | 'right' 'bottom' -
id string `brn-dialog-${++dialogIdSequence}` -
state BrnDialogState | null null -
role BrnDialogOptions['role'] this._defaultOptions.role -
hasBackdrop boolean this._defaultOptions.hasBackdrop -
positionStrategy BrnDialogOptions['positionStrategy'] this._defaultOptions.positionStrategy -
scrollStrategy BrnDialogOptions['scrollStrategy'] | 'close' | 'reposition' | null this._defaultOptions.scrollStrategy -
restoreFocus BrnDialogOptions['restoreFocus'] this._defaultOptions.restoreFocus -
closeOnOutsidePointerEvents boolean this._defaultOptions.closeOnOutsidePointerEvents -
attachTo BrnDialogOptions['attachTo'] this._defaultOptions.attachTo -
attachPositions BrnDialogOptions['attachPositions'] this._defaultOptions.attachPositions -
autoFocus BrnDialogOptions['autoFocus'] this._defaultOptions.autoFocus -
disableClose boolean this._defaultOptions.disableClose -
aria-describedby BrnDialogOptions['ariaDescribedBy'] this._defaultOptions.ariaDescribedBy -
aria-labelledby BrnDialogOptions['ariaLabelledBy'] this._defaultOptions.ariaLabelledBy -
aria-label BrnDialogOptions['ariaLabel'] this._defaultOptions.ariaLabel -
aria-modal boolean this._defaultOptions.ariaModal -

Outputs

PropTypeDefaultDescription
closed TResult --
stateChanged BrnDialogState --
Dropdown Menu Dialog