Skip to main content
VelinStyle v0.8.0
⌂ Home
  1. Docs
  2. Components
  3. Drawer

Drawer

The <velin-drawer> Web Component slides an off-canvas panel from any of the four sides with an overlay backdrop, focus trap, and body scroll lock.

Basic Example

Drawer content goes here.

<velin-drawer title="Navigation" id="myDrawer">
  <p>Drawer content goes here.</p>
</velin-drawer>

<button onclick="document.getElementById('myDrawer').open()">
  Open Drawer
</button>

Four Sides

Use the side attribute: start (default), end, top, or bottom.

<velin-drawer side="start" title="Left">…</velin-drawer>
<velin-drawer side="end" title="Right">…</velin-drawer>
<velin-drawer side="top" title="Top">…</velin-drawer>
<velin-drawer side="bottom" title="Bottom">…</velin-drawer>

Accessibility

CSS Variables

VariableDescription
--velin-color-overlayBackdrop overlay colour
--velin-color-surface-brightDrawer background
--velin-shadow-xlDrawer shadow
--velin-z-overlayOverlay z-index (400)
--velin-z-modalDrawer z-index (500)

JavaScript API

Attributes

AttributeTypeDescription
openBooleanWhether the drawer is visible
sideStringstart | end | top | bottom
titleStringHeader title text & aria-label

Methods

MethodDescription
open()Open the drawer
close()Close the drawer

Events

EventDescription
velin-closeFired when the drawer closes

Theme wählen