For a list of sections inside the drawer take CdsList; for navigating the subsections of a single page take CdsTabs. The drawer is a part of the CdsLayout frame, but unlike the other parts it also works on its own: with the
fixedprop it sticks to the window without a layout.
Anatomy
The drawer consists of a scrollable navigation list and two pinned areas: prepend on top — for a logo or a profile, append at the bottom — for the sign-out and utility links. The border prop draws borders between the areas.
Variations
Permanent drawer
The permanent prop keeps the drawer on the screen at all times. Without it the drawer hides on screens narrower than 1056 px — the content gets the whole width, and the navigation is opened by a button.
Collapsible drawer
A regular drawer follows v-model at any screen width. On a wide screen it sits in the layout, and when closed it gives its place back to the content. On a narrow screen the same drawer slides out over the content. When the screen crosses 1056 px, the drawer closes and opens back on its own; disable-resize-watcher turns this sync off. The width prop sets the width in pixels, and the layout shifts the content by exactly that much.
Temporary drawer
The temporary prop turns the drawer into a sliding one: it takes no place in the layout, opens through v-model and closes on a click on the overlay or on Esc. The @opened and @closed events report the change of state.
On touch screens a sliding drawer can be pulled out with a swipe from the screen edge and put away with a swipe back. The touchless prop turns the gestures off.
Without the scrim
The scrim prop controls the backdrop under a sliding drawer. false removes it: the content under the drawer stays clickable, but a click outside no longer closes the drawer, so provide your own button for that. A string instead of true sets the backdrop color; pass it with transparency, for example rgb(0 0 0 / 0.3), or the content under the drawer is hidden completely.
Protection from an accidental close
The persistent prop keeps a click on the scrim and the Esc key from closing the drawer: only v-model closes it. It suits a drawer with a form, where a stray click outside would wipe the input.
Minified drawer
The minified prop shrinks the drawer down to icons and gives the width back to the content. On hover the drawer expands over the page without pushing it, so the section labels stay reachable.
Position
The right prop moves the drawer to the right edge. The application navigation usually lives on the left, and the context of the current record — history, comments, filters — on the right. Both drawers can work in the same layout at once.
Color
The bg-color prop paints the background of the drawer with a palette alias, color paints the text and the icons inside. A dark drawer next to light content emphasizes the border of the working area.
Background image
The image prop puts an image from a URL under the drawer content, and the image slot takes custom background markup. Color the text on top with the color prop so it stays readable.
Slots
| Slot | Description |
|---|---|
prepend | Pinned area on top: logo, profile |
default | Navigation items |
append | Pinned area at the bottom: sign-out, utility links |
image | Background under the drawer content |
The fixed-slots prop keeps prepend and append in place and gives the scroll to the list of sections only — long navigation no longer pushes the sign-out button past the edge.
Guidelines
Scenarios
Application navigation
A logo in prepend, the sections in a CdsList with active on the current one, a sign-out button in append. The lhh lpr fff layout scheme gives the top left corner to the drawer, so it starts from the very top and reads as the backbone of the application.
Notification panel
A right drawer with temporary opens from an icon in the header, shows the list and closes on a click on the overlay. It takes no place in the layout, so the main content is not rebuilt when it opens.
API
Props
| Name | Type | Default | Description |
|---|---|---|---|
bgColor | string | undefined | — | Background color of the component |
border | boolean | undefined | false | Adds borders between the sections (prepend/append). |
captureFocus | boolean | undefined | true | Returns the focus back into the content if it has left it — for example on Tab from the end of the page. A mouse click does not steal the focus. |
color | string | undefined | — | Component color |
disableResizeWatcher | boolean | undefined | false | Does not sync v-model with the screen width. By default a regular drawer closes when the screen narrows and it becomes a sliding one, and opens back on a wide screen. |
fixed | boolean | undefined | false | Applies position: fixed. |
fixedSlots | boolean | undefined | false | Uses an inner scroll for the content section. |
height | string | number | undefined | — | Component height |
image | string | undefined | — | Background image of the drawer (URL). The image slot is available for custom background markup. |
maxHeight | string | number | undefined | — | Maximum component height |
maxWidth | string | number | undefined | — | Maximum component width |
minHeight | string | number | undefined | — | Minimum component height |
minified | boolean | undefined | false | Minified look (icons only) until the mouse hovers over it. |
minWidth | string | number | undefined | — | Minimum component width |
modelValue | boolean | null | undefined | null | Shows/hides the drawer (v-model). Without it a regular drawer is open on a wide screen, and a sliding one is closed. |
permanent | boolean | undefined | false | Always visible, regardless of the screen size. |
persistent | boolean | undefined | false | A click on the scrim and the Esc key do not close the drawer, only v-model does. For drawers with a form where an accidental close loses the input. |
retainFocus | boolean | undefined | true | Traps Tab navigation inside the content: from the last focusable element the focus moves to the first one and back. |
right | boolean | undefined | false | Positions the drawer on the right. |
scrim | string | boolean | undefined | true | Backdrop under the drawer while it covers the content. false removes it entirely: the content
stays clickable and the drawer closes only with Esc or through v-model; a string sets its color. |
tag | string | JSXComponent<any> | undefined | 'aside' | Custom HTML tag or component to render |
temporary | boolean | undefined | false | Temporary drawer: slides out over the content at any screen width, opens through v-model and closes on the overlay. On a narrow screen any non-permanent drawer behaves this way. |
theme | string | undefined | — | Component theme |
touchless | boolean | undefined | false | Disables gestures: a sliding drawer neither opens with a swipe from the screen edge nor closes with a swipe. |
width | string | number | undefined | 240 | The drawer width, px. It also goes into the layout: the content shifts by exactly this width. |
Events
| Name | Type | Description |
|---|---|---|
closed | [value: boolean] | The drawer has closed. |
opened | [value: boolean] | The drawer has opened. |
update:modelValue | [value: boolean] | The v-model value has changed. |
Slots
| Name | Type | Description |
|---|---|---|
append | any | Content after the navigation. |
default | any | Navigation items (CdsList). |
image | { image: string | undefined; } | Custom drawer background instead of CdsImage from the image prop; stretches under the content. |
prepend | any | Content before the navigation. |
Exposed
| Name | Type | Description |
|---|---|---|
drawerRef | HTMLElement | undefined | Ref to the root DOM element of the drawer. |