Offcanvas

Extend the Sidenav into a full offcanvas panel that slides in from any edge. Uses the existing useSidenav API with positional modifiers.

VdOffcanvas Component
Left (Default)
Right
Top
Bottom
Using data-vd-position

You can set the slide direction entirely through the data-vd-position attribute instead of adding directional CSS classes. The JS reads this attribute at init time and applies the correct transform.

API Reference

Wiring

import { ref } from 'vue';
import { useSidenav } from "@vanduo-oss/vd3";

const root = ref<HTMLElement | null>(null);
useSidenav(root);   // wires [data-sidenav-toggle] triggers; cleanup on unmount

CSS Classes

ClassDescriptionType
.vd-offcanvasBase offcanvas panel — extends .vd-sidenav behaviourBase
.vd-offcanvas-topSlide from the top edge (full-width)Modifier
.vd-offcanvas-bottomSlide from the bottom edge (full-width)Modifier
.vd-offcanvas-rightSlide from the right edgeModifier
.vd-sidenav-topLegacy alias for .vd-offcanvas-topModifier
.vd-sidenav-bottomLegacy alias for .vd-offcanvas-bottomModifier
.is-openApplied when the panel is visibleState

Data Attributes

AttributeDescriptionDefault
data-vd-positionSet slide direction: top, right, bottom, or leftleft
data-sidenav-togglePlace on trigger element — value is the selector for the offcanvas (e.g. "#my-panel")—

VdOffcanvas Component API

Prop / Event / SlotDescription
v-model (modelValue)boolean — controls open/closed offcanvas visibility.
:placement"right" (default) | "left" | "top" | "bottom".
:titlestring — header title and accessible dialog aria-label.
:closeOnBackdropboolean (default true) — close when clicking the overlay backdrop.
:closeOnEscboolean (default true) — close when pressing Escape.
:animatedboolean (default true) — smooth sliding transition using Fibonacci timing and golden easing.
@closeEmitted when the offcanvas panel closes.
#header / defaultNamed #header slot for custom header content and default slot for panel body.

Composable API

SymbolDescription
useSidenav(root)Composable — wires every [data-sidenav-toggle] trigger inside the root ref (overlay, close button, ESC, scroll-lock). Call once in setup().
(automatic cleanup)Listeners and the body overlay are removed on component unmount.

Events

EventDescriptionDetail
sidenav:openFired on the offcanvas element after it becomes visible{ position }
sidenav:closeFired on the offcanvas element after it is hidden{ position }
Accessibility
  • VdOffcanvas renders role="dialog" with aria-modal="true", traps focus inside the panel while open, and returns focus to the previously focused element on close
  • useSidenav panels get role="navigation" and a synced aria-hidden; they do not trap focus — use VdOffcanvas when the panel needs modal dialog semantics
  • Close button includes aria-label="Close" for assistive technology
  • Pressing Escape closes the offcanvas panel
  • Overlay backdrop blocks interaction with the page beneath
  • [data-sidenav-toggle] triggers receive aria-controls and an aria-expanded that tracks the open/closed state