Drawer
import {DrawerModule} from "@qualcomm-ui/angular/drawer"Overview
The drawer's API is similar to the Dialog component.
Examples
Placement End
The drawer's default placement is end, which maps to the right side of the screen in LTR languages and the left side in RTL languages.
Placement Start
Use placement start to change the placement to the left side of the screen.
<div placement="start" q-drawer-root>Controlled State
Set the initial visibility using the defaultOpen prop, or use open and openChanged to control the visibility manually. These props follow our controlled state pattern.
Custom Container
Use the container prop of the <q-portal> component to render the drawer in a custom container. You'll need to override the positioner's default styles to position the drawer correctly.
Consider setting closeOnInteractOutside to false to prevent the drawer from closing when interacting outside the drawer.
Drawer Title
import {Component} from "@angular/core"
import {ButtonModule} from "@qualcomm-ui/angular/button"
import {DrawerModule} from "@qualcomm-ui/angular/drawer"
import {PortalComponent} from "@qualcomm-ui/angular-core/portal"
@Component({
imports: [DrawerModule, ButtonModule, PortalComponent],
selector: "drawer-custom-container-demo",
template: `
<div
closeOnEscape="false"
closeOnInteractOutside="false"
preventScroll="false"
q-drawer-root
trapFocus="false"
>
<div
#containerRef
class="border-neutral-03 relative flex h-96 w-[600px] overflow-hidden border p-8"
>
<button emphasis="primary" q-button q-drawer-trigger variant="fill">
Open Drawer
</button>
</div>
<q-portal [container]="containerRef">
<div class="absolute z-0 h-full w-full" q-drawer-positioner>
<section q-drawer-content>
<div q-drawer-body>
<button q-drawer-close-button></button>
<h2 q-drawer-heading>Drawer Title</h2>
<div q-drawer-description>Drawer Description</div>
</div>
<div q-drawer-footer>
<button q-button q-drawer-close-trigger size="sm" variant="fill">
Close
</button>
</div>
</section>
</div>
</q-portal>
</div>
`,
})
export class DrawerCustomContainerDemo {}
Shortcuts
<q-drawer-floating-portal>
A helper component that combines the portal, positioner, and content components. This shortcut is equivalent to:
<q-portal>
<div q-drawer-backdrop></div>
<div q-drawer-positioner>
<section q-drawer-content><ng-content /></section>
</div>
</q-portal>API
The Drawer shares many of its props and data attributes with the Dialog component.
<q-drawer-root>
| Prop | Type | Default |
|---|---|---|
Human-readable label for the dialog, used when the dialog title is not rendered | string | |
Whether to close the dialog when the escape key is pressed | boolean | true |
Whether to close the dialog when the outside is clicked | boolean | true |
The initial open state of the dialog when rendered.
Use when you don't need to control the open state of the dialog. | boolean | |
The document's text/writing direction. | 'ltr' | 'rtl' | "ltr" |
The style variant of the drawer's indicator. | | 'info' | 'neutral' |
Element to receive focus when the dialog is closed | () => HTMLElement | |
A root node to correctly resolve the Document in custom environments. i.e.,
Iframes, Electron. | () => | |
Whether to synchronize the present change immediately or defer it to the next
frame. | boolean | false |
Element to receive focus when the dialog is opened | () => HTMLElement | |
When true, the component will not be rendered in the DOM until it becomes
visible or active. | boolean | false |
Whether to prevent pointer interaction outside the element and hide all content
below it | boolean | true |
The controlled open state of the dialog | boolean | |
The persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | Array< | |
The horizontal placement of the drawer within the viewport. | | 'start' | 'end' |
The controlled presence of the node. | boolean | |
Whether to prevent scrolling behind the dialog when it's opened | boolean | true |
Whether to restore focus to the element that had focus before the dialog was
opened | boolean | true |
The dialog's role | | 'dialog' | 'dialog' |
Defines the scroll behavior of the drawer content when modal content exceeds
viewport height. | | 'inside' | 'outside' |
The size of the drawer's content area and fonts. A smaller size uses less
horizontal space. | 'sm' | 'md' | 'sm' |
Whether to allow the initial presence animation. | boolean | false |
Whether to trap focus inside the dialog when it's opened | boolean | true |
When true, the component will be completely removed from the DOM when it
becomes inactive or hidden, rather than just being hidden with CSS. | boolean | false |
Function called when the escape key is pressed | KeyboardEvent | |
Function called when the animation ends in the closed state | void | |
Function called when the focus is moved outside the component | CustomEvent<{ | |
Function called when an interaction happens outside the component | | CustomEvent<{event?: E}> | |
Fired when the dialog opens or closes. | boolean | |
Function called when the pointer is pressed down outside the component | CustomEvent<{ | |
Function called when this layer is closed due to a parent layer being closed | CustomEvent<{ |
stringbooleanbooleanboolean'ltr' | 'rtl'
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
() => HTMLElement
() =>
| Node
| ShadowRoot
| Document
boolean() => HTMLElement
booleanbooleanbooleanArray<
() => Element
>
- should not have pointer-events disabled
- should not trigger the dismiss event
| 'start'
| 'end'
booleanbooleanboolean| 'dialog'
| 'alertdialog'
| 'inside'
| 'outside'
'sm' | 'md'
booleanbooleanbooleanKeyboardEventvoidCustomEvent<{
event?: E
}>
| CustomEvent<{event?: E}>
| CustomEvent<{event?: E}>
booleanCustomEvent<{
event?: E
}>
CustomEvent<{
originalIndex: number
originalLayer: HTMLElement
targetIndex: number
targetLayer: HTMLElement
}>
<q-drawer-floating-portal>
q-drawer-backdrop
| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__backdrop' |
data-part | 'backdrop' |
data-scope | 'dialog' |
data-state | | 'open' |
hidden | boolean |
class'qui-dialog__backdrop'data-part'backdrop'data-scope'dialog'data-state| 'open'
| 'closed'
hiddenbooleanq-drawer-positioner
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-drawer__positioner' |
data-part | 'positioner' |
data-placement | | 'start' |
data-scope | 'dialog' |
style |
class'qui-drawer__positioner'data-part'positioner'data-placement| 'start'
| 'end'
data-scope'dialog'styleq-drawer-content
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-drawer__content' |
data-part | 'content' |
data-placement | | 'start' |
data-scope | 'dialog' |
data-size | 'sm' | 'md' |
data-state | | 'open' |
hidden | boolean |
tabIndex | -1 |
class'qui-drawer__content'data-part'content'data-placement| 'start'
| 'end'
data-scope'dialog'data-size'sm' | 'md'
data-state| 'open'
| 'closed'
hiddenbooleantabIndex-1
q-drawer-body
| Prop | Type |
|---|---|
Hides the indicator icon. | boolean |
boolean| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__body' |
data-part | 'body' |
data-scope | 'dialog' |
data-size | 'sm' | 'md' |
class'qui-dialog__body'data-part'body'data-scope'dialog'data-size'sm' | 'md'
q-drawer-heading
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__heading' |
data-part | 'heading' |
data-scope | 'dialog' |
data-size | 'sm' | 'md' |
class'qui-dialog__heading'data-part'heading'data-scope'dialog'data-size'sm' | 'md'
q-drawer-footer
| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__footer' |
data-part | 'footer' |
data-scope | 'dialog' |
data-size | 'sm' | 'md' |
class'qui-dialog__footer'data-part'footer'data-scope'dialog'data-size'sm' | 'md'
q-drawer-indicator-icon
| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__indicator-icon' |
data-emphasis | | 'info' |
data-size | 'sm' | 'md' |
class'qui-dialog__indicator-icon'data-emphasis| 'info'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
data-size'sm' | 'md'
q-drawer-close-button
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility. | string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-dialog__close-button' |
data-part | 'close-trigger' |
data-scope | 'dialog' |
class'qui-dialog__close-button'data-part'close-trigger'data-scope'dialog'