Guide

Framework integrations

Use Drawer in React, Vue, Svelte, Astro, Shopify and WordPress with accessible triggers, browser assets and explicit client lifecycle ownership.

Drawer provides a browser API, not React, Vue or Svelte components. Use the same public createDrawer() function after your trigger mounts; destroy the instance when its owner unmounts. Keep one owner for the dialog DOM. Do not pass JSX, Vue VNodes or Svelte snippets as content: use text, an HTMLElement or a function returning one.

JavaScript and TypeScript

Start with the working files. Plain JavaScript needs no types or wrappers. TypeScript can import VanillaDrawerOptions and VanillaDrawerController from the same package. Use satisfies VanillaDrawerOptions when checking a reusable options object; see the TypeScript reference for every exported shape.

React, Vue and Svelte

These are client components for an existing framework application. Install Drawer, save the component and its CSS sibling together, then render Filters using your framework. The stylesheet is ordinary global CSS because the runtime mounts its panel outside the component DOM. Package CSS comes first. Each mounted component gets an independent id, updates aria-expanded, and destroys only its own drawer.

React

React

Filters.jsx
'use client'

import { useEffect, useId, useRef, useState } from 'react'
import { createDrawer } from '@samline/drawer'
import '@samline/drawer/style.css'
import './drawer.css'

export const Filters = () => {
  const triggerRef = useRef(null)
  const id = useId()
  const [open, setOpen] = useState(false)

  useEffect(() => {
    const trigger = triggerRef.current
    const drawer = createDrawer({
      id,
      triggerElement: trigger,
      title: 'Your filters',
      content: 'Add your own filter controls here.',
      contentClassName: 'demo-drawer',
      overlayClassName: 'demo-overlay',
      autoFocus: true,
      showHandle: true,
      closeButton: { ariaLabel: 'Close filters' },
      onOpenChange: setOpen,
    })
    return () => drawer.destroy()
  }, [id])

  return (
    <button ref={triggerRef} type="button" aria-haspopup="dialog" aria-expanded={open}>
      Open filters
    </button>
  )
}

CSS

drawer.css
.demo-drawer button {
  font: inherit;
  cursor: pointer;
  padding: 0.75rem 1rem;
}
.demo-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  z-index: 101;
}
.demo-drawer {
  display: flex;
  flex-direction: column;
  position: fixed;
  box-sizing: border-box;
  background: #faf9fc;
  color: #24212b;
  z-index: 101;
  padding: 2rem;
  max-height: 90dvh;
  outline: none;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 1.5rem 1.5rem 0 0;
  min-height: 18rem;
}

.demo-drawer [data-drawer-title] {
  margin: 1rem 0;
  font-size: 1.75rem;
  line-height: 1.15;
  padding-right: 3rem;
}
.demo-drawer [data-drawer-description] {
  margin: 0 0 1.5rem;
}
.demo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.demo-body {
  display: grid;
  gap: 1rem;
  width: min(100%, 52rem);
  margin-inline: auto;
}
.demo-body > button,
.demo-body form > button {
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}
.demo-scene {
  display: grid;
  border: 0.0625rem solid #d9cbd5;
  border-radius: 0.875rem;
  background: #f3edf3;
}
.demo-scene-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 1rem;
}
.demo-scene-row + .demo-scene-row {
  border-top: 0.0625rem solid #d9cbd5;
}
.demo-scene-row p {
  color: #625361;
  font-size: 0.875rem;
}

.demo-menu {
  display: grid;
  gap: 0.75rem;
}
.demo-menu-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  border: 0.0625rem solid #d9cbd5;
  border-radius: 0.875rem;
  color: inherit;
  background: #f3edf3;
}
.demo-menu-item[hidden] {
  display: none;
}
.demo-menu-copy {
  display: grid;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}
.demo-menu-copy > span,
.demo-hint {
  font-size: 0.875rem;
  color: #625361;
}
.demo-menu-icon {
  display: grid;
  place-items: center;
  flex: 0 0 2.5rem;
  height: 2.5rem;
  color: #a32379;
}
.demo-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: #a32379;
}
.demo-body h3,
.demo-body p {
  margin: 0;
}
.demo-body:focus-visible {
  outline: 0.125rem solid #a32379;
  outline-offset: -0.125rem;
}
.demo-body ul {
  margin: 0;
  padding-left: 1.25rem;
}
.demo-body li + li {
  margin-top: 0.5rem;
}
.demo-drawer [data-drawer-close] {
  position: sticky;
  order: -1;
  flex: 0 0 auto;
  top: 0;
  display: block;
  margin-left: auto;
  z-index: 1;
  background: #faf9fc;
}
.demo-body label,
.demo-body form {
  display: grid;
  gap: 0.75rem;
}
.demo-body input,
.demo-body select,
.demo-body textarea {
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.75rem;
}
.demo-body section + section {
  margin-top: 1.5rem;
}
#demo-result {
  display: block;
}
.demo-drawer [data-drawer-handle] {
  order: -2;
  flex-shrink: 0;
  margin-inline: auto;
}
.demo-drawer [data-drawer-body] {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.demo-drawer [data-drawer-title],
.demo-drawer [data-drawer-description] {
  flex-shrink: 0;
  width: min(100%, 52rem);
  margin-inline: auto;
  box-sizing: border-box;
}

.demo-drawer:focus-visible,
button:focus-visible {
  outline: 0.125rem solid #a32379;
  outline-offset: 0.1875rem;
}

Vue

Vue

Filters.vue
<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { createDrawer } from '@samline/drawer'
import '@samline/drawer/style.css'
import './drawer.css'

const triggerRef = ref(null)
const open = ref(false)
let drawer

onMounted(() => {
  const trigger = triggerRef.value
  drawer = createDrawer({
    id: crypto.randomUUID(),
    triggerElement: trigger,
    title: 'Your filters',
    content: 'Add your own filter controls here.',
    contentClassName: 'demo-drawer',
    overlayClassName: 'demo-overlay',
    autoFocus: true,
    showHandle: true,
    closeButton: { ariaLabel: 'Close filters' },
    onOpenChange: value => {
      open.value = value
    },
  })
})
onUnmounted(() => drawer?.destroy())
</script>

<template>
  <button ref="triggerRef" type="button" aria-haspopup="dialog" :aria-expanded="open">
    Open filters
  </button>
</template>

CSS

drawer.css
.demo-drawer button {
  font: inherit;
  cursor: pointer;
  padding: 0.75rem 1rem;
}
.demo-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  z-index: 101;
}
.demo-drawer {
  display: flex;
  flex-direction: column;
  position: fixed;
  box-sizing: border-box;
  background: #faf9fc;
  color: #24212b;
  z-index: 101;
  padding: 2rem;
  max-height: 90dvh;
  outline: none;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 1.5rem 1.5rem 0 0;
  min-height: 18rem;
}

.demo-drawer [data-drawer-title] {
  margin: 1rem 0;
  font-size: 1.75rem;
  line-height: 1.15;
  padding-right: 3rem;
}
.demo-drawer [data-drawer-description] {
  margin: 0 0 1.5rem;
}
.demo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.demo-body {
  display: grid;
  gap: 1rem;
  width: min(100%, 52rem);
  margin-inline: auto;
}
.demo-body > button,
.demo-body form > button {
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}
.demo-scene {
  display: grid;
  border: 0.0625rem solid #d9cbd5;
  border-radius: 0.875rem;
  background: #f3edf3;
}
.demo-scene-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 1rem;
}
.demo-scene-row + .demo-scene-row {
  border-top: 0.0625rem solid #d9cbd5;
}
.demo-scene-row p {
  color: #625361;
  font-size: 0.875rem;
}

.demo-menu {
  display: grid;
  gap: 0.75rem;
}
.demo-menu-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  border: 0.0625rem solid #d9cbd5;
  border-radius: 0.875rem;
  color: inherit;
  background: #f3edf3;
}
.demo-menu-item[hidden] {
  display: none;
}
.demo-menu-copy {
  display: grid;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}
.demo-menu-copy > span,
.demo-hint {
  font-size: 0.875rem;
  color: #625361;
}
.demo-menu-icon {
  display: grid;
  place-items: center;
  flex: 0 0 2.5rem;
  height: 2.5rem;
  color: #a32379;
}
.demo-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: #a32379;
}
.demo-body h3,
.demo-body p {
  margin: 0;
}
.demo-body:focus-visible {
  outline: 0.125rem solid #a32379;
  outline-offset: -0.125rem;
}
.demo-body ul {
  margin: 0;
  padding-left: 1.25rem;
}
.demo-body li + li {
  margin-top: 0.5rem;
}
.demo-drawer [data-drawer-close] {
  position: sticky;
  order: -1;
  flex: 0 0 auto;
  top: 0;
  display: block;
  margin-left: auto;
  z-index: 1;
  background: #faf9fc;
}
.demo-body label,
.demo-body form {
  display: grid;
  gap: 0.75rem;
}
.demo-body input,
.demo-body select,
.demo-body textarea {
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.75rem;
}
.demo-body section + section {
  margin-top: 1.5rem;
}
#demo-result {
  display: block;
}
.demo-drawer [data-drawer-handle] {
  order: -2;
  flex-shrink: 0;
  margin-inline: auto;
}
.demo-drawer [data-drawer-body] {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.demo-drawer [data-drawer-title],
.demo-drawer [data-drawer-description] {
  flex-shrink: 0;
  width: min(100%, 52rem);
  margin-inline: auto;
  box-sizing: border-box;
}

.demo-drawer:focus-visible,
button:focus-visible {
  outline: 0.125rem solid #a32379;
  outline-offset: 0.1875rem;
}

Svelte

Svelte

Filters.svelte
<script>
import { onMount } from 'svelte'
import { createDrawer } from '@samline/drawer'
import '@samline/drawer/style.css'
import './drawer.css'

let trigger
let open = $state(false)

onMount(() => {
  const drawer = createDrawer({
    id: crypto.randomUUID(),
    triggerElement: trigger,
    title: 'Your filters',
    content: 'Add your own filter controls here.',
    contentClassName: 'demo-drawer',
    overlayClassName: 'demo-overlay',
    autoFocus: true,
    showHandle: true,
    closeButton: { ariaLabel: 'Close filters' },
    onOpenChange: value => { open = value },
  })
  return () => drawer.destroy()
})
</script>

<button bind:this={trigger} type="button" aria-haspopup="dialog" aria-expanded={open}>Open filters</button>

CSS

drawer.css
.demo-drawer button {
  font: inherit;
  cursor: pointer;
  padding: 0.75rem 1rem;
}
.demo-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  z-index: 101;
}
.demo-drawer {
  display: flex;
  flex-direction: column;
  position: fixed;
  box-sizing: border-box;
  background: #faf9fc;
  color: #24212b;
  z-index: 101;
  padding: 2rem;
  max-height: 90dvh;
  outline: none;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 1.5rem 1.5rem 0 0;
  min-height: 18rem;
}

.demo-drawer [data-drawer-title] {
  margin: 1rem 0;
  font-size: 1.75rem;
  line-height: 1.15;
  padding-right: 3rem;
}
.demo-drawer [data-drawer-description] {
  margin: 0 0 1.5rem;
}
.demo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.demo-body {
  display: grid;
  gap: 1rem;
  width: min(100%, 52rem);
  margin-inline: auto;
}
.demo-body > button,
.demo-body form > button {
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}
.demo-scene {
  display: grid;
  border: 0.0625rem solid #d9cbd5;
  border-radius: 0.875rem;
  background: #f3edf3;
}
.demo-scene-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 1rem;
}
.demo-scene-row + .demo-scene-row {
  border-top: 0.0625rem solid #d9cbd5;
}
.demo-scene-row p {
  color: #625361;
  font-size: 0.875rem;
}

.demo-menu {
  display: grid;
  gap: 0.75rem;
}
.demo-menu-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  border: 0.0625rem solid #d9cbd5;
  border-radius: 0.875rem;
  color: inherit;
  background: #f3edf3;
}
.demo-menu-item[hidden] {
  display: none;
}
.demo-menu-copy {
  display: grid;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}
.demo-menu-copy > span,
.demo-hint {
  font-size: 0.875rem;
  color: #625361;
}
.demo-menu-icon {
  display: grid;
  place-items: center;
  flex: 0 0 2.5rem;
  height: 2.5rem;
  color: #a32379;
}
.demo-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: #a32379;
}
.demo-body h3,
.demo-body p {
  margin: 0;
}
.demo-body:focus-visible {
  outline: 0.125rem solid #a32379;
  outline-offset: -0.125rem;
}
.demo-body ul {
  margin: 0;
  padding-left: 1.25rem;
}
.demo-body li + li {
  margin-top: 0.5rem;
}
.demo-drawer [data-drawer-close] {
  position: sticky;
  order: -1;
  flex: 0 0 auto;
  top: 0;
  display: block;
  margin-left: auto;
  z-index: 1;
  background: #faf9fc;
}
.demo-body label,
.demo-body form {
  display: grid;
  gap: 0.75rem;
}
.demo-body input,
.demo-body select,
.demo-body textarea {
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.75rem;
}
.demo-body section + section {
  margin-top: 1.5rem;
}
#demo-result {
  display: block;
}
.demo-drawer [data-drawer-handle] {
  order: -2;
  flex-shrink: 0;
  margin-inline: auto;
}
.demo-drawer [data-drawer-body] {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.demo-drawer [data-drawer-title],
.demo-drawer [data-drawer-description] {
  flex-shrink: 0;
  width: min(100%, 52rem);
  margin-inline: auto;
  box-sizing: border-box;
}

.demo-drawer:focus-visible,
button:focus-visible {
  outline: 0.125rem solid #a32379;
  outline-offset: 0.1875rem;
}

React’s Effect cleanup also handles its development setup/cleanup cycle. In SSR applications, keep drawer creation in useEffect, Vue onMounted, or Svelte onMount; importing a module is not permission to create a DOM instance on the server.

The patterns follow React Effects, Vue mount/unmount hooks and Svelte onMount cleanup.

Astro

Use a processed client <script> with the JavaScript setup, not frontmatter, for DOM creation. Astro emits static markup and runs the script in the browser. If you enable client-side navigation, set up the current page after astro:page-load, destroy its instances on astro:before-swap, and avoid adding document listeners again on each visit. Ordinary full-page navigation can use the provided persisted-pagehide cleanup.

Shopify

Use a theme section and theme assets. Copy the matching published release of dist/browser/drawer.global.js to assets/drawer.global.js and dist/style.css to assets/drawer.css; save the JavaScript and CSS below beside them. Include the loader once in layout/theme.liquid, then add sections/drawer-filters.liquid through the theme editor. Do not put another runtime script tag inside every section.

Section

sections/drawer-filters.liquid
<section data-drawer-widget>
  <button type="button" data-open aria-haspopup="dialog" aria-expanded="false">Open filters</button>
  <template data-content><div><p>Choose what you want to see.</p><label>Category<select><option>All products</option><option>Books</option><option>Tools</option></select></label></div></template>
</section>

{% schema %}
{"name":"Drawer example","presets":[{"name":"Drawer example"}]}
{% endschema %}

Layout

layout/theme.liquid
{{ 'drawer.css' | asset_url | stylesheet_tag }}
{{ 'integration.css' | asset_url | stylesheet_tag }}
<script src="{{ 'drawer.global.js' | asset_url }}" defer></script>
<script src="{{ 'integration.js' | asset_url }}" defer></script>

JavaScript

assets/integration.js
const instances = new Map()
const mount = scope => {
  scope.querySelectorAll('[data-drawer-widget]').forEach(root => {
    if (instances.has(root)) return
    const trigger = root.querySelector('[data-open]')
    const template = root.querySelector('template')
    const drawer = window.Drawer.createDrawer({
      id: crypto.randomUUID(),
      triggerElement: trigger,
      title: 'Product filters',
      content: () => template.content.firstElementChild.cloneNode(true),
      contentClassName: 'cms-panel',
      overlayClassName: 'cms-overlay',
      autoFocus: true,
      showHandle: true,
      closeButton: { icon: '×', ariaLabel: 'Close filters' },
      onOpenChange: open => trigger.setAttribute('aria-expanded', String(open)),
    })
    instances.set(root, () => {
      drawer.destroy()
      trigger.setAttribute('aria-expanded', 'false')
    })
  })
}
const unmount = scope => {
  for (const [root, dispose] of instances) {
    if (scope.contains(root)) {
      dispose()
      instances.delete(root)
    }
  }
}
mount(document)
document.addEventListener('shopify:section:load', event => mount(event.target))
document.addEventListener('shopify:section:unload', event => unmount(event.target))
window.addEventListener('pagehide', event => {
  if (!event.persisted) unmount(document)
})

CSS

assets/integration.css
.cms-overlay {
  position: fixed;
  inset: 0;
  z-index: 101;
  background: rgb(0 0 0 / 45%);
}
.cms-panel {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  padding: 1.5rem;
  max-height: 85dvh;
  background: #faf9fc;
  color: #24212b;
  border-radius: 1.5rem 1.5rem 0 0;
}
.cms-panel [data-drawer-body] {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cms-panel [data-drawer-title],
.cms-panel [data-drawer-handle],
.cms-panel [data-drawer-close] {
  flex-shrink: 0;
}
.cms-panel [data-drawer-title] {
  font-size: 1.5rem;
  margin: 1rem 0;
}
.cms-panel [data-drawer-close] {
  display: block;
  margin: 1rem 0 0 auto;
}
.cms-panel label {
  display: grid;
  gap: 0.75rem;
}
.cms-panel select,
.cms-panel button {
  font: inherit;
  padding: 0.75rem;
}

Each section gets an independent id. The loader handles shopify:section:load and shopify:section:unload; removing an open section destroys its drawer and releases modal effects. The template is cloned each time the panel opens. Retain application data outside that disposable DOM when edits must survive closing. See Shopify’s section events and theme asset loading.

WordPress

Create wp-content/plugins/drawer-example/ with the plugin PHP file below and an assets/ folder. Save the same pinned runtime files there as drawer.global.js and drawer.css, plus the provided integration.js and integration.css. Activate Drawer example, then put [drawer_filters] in a Shortcode block on an ordinary post or page.

Plugin

drawer-example.php
<?php
/**
 * Plugin Name: Drawer example
 */
add_action('wp_enqueue_scripts', static function () {
    $post = get_post();
    if (!is_singular() || !$post || !has_shortcode($post->post_content, 'drawer_filters')) return;
    $assets = plugin_dir_url(__FILE__) . 'assets/';
    wp_enqueue_style('drawer-runtime', $assets . 'drawer.css', [], '5.1.2');
    wp_enqueue_style('drawer-example', $assets . 'integration.css', ['drawer-runtime'], '1.0.0');
    wp_enqueue_script('drawer-runtime', $assets . 'drawer.global.js', [], '5.1.2', ['strategy' => 'defer', 'in_footer' => true]);
    wp_enqueue_script('drawer-example', $assets . 'integration.js', ['drawer-runtime'], '1.0.0', ['strategy' => 'defer', 'in_footer' => true]);
});
add_shortcode('drawer_filters', static fn () => '<section data-drawer-widget>
  <button type="button" data-open aria-haspopup="dialog" aria-expanded="false">Open filters</button>
  <template data-content><div><p>Choose what you want to see.</p><label>Category<select><option>All products</option><option>Books</option><option>Tools</option></select></label></div></template>
</section>');

JavaScript

assets/integration.js
const instances = new Map()
const mount = scope => {
  scope.querySelectorAll('[data-drawer-widget]').forEach(root => {
    if (instances.has(root)) return
    const trigger = root.querySelector('[data-open]')
    const template = root.querySelector('template')
    const drawer = window.Drawer.createDrawer({
      id: crypto.randomUUID(),
      triggerElement: trigger,
      title: 'Product filters',
      content: () => template.content.firstElementChild.cloneNode(true),
      contentClassName: 'cms-panel',
      overlayClassName: 'cms-overlay',
      autoFocus: true,
      showHandle: true,
      closeButton: { icon: '×', ariaLabel: 'Close filters' },
      onOpenChange: open => trigger.setAttribute('aria-expanded', String(open)),
    })
    instances.set(root, () => {
      drawer.destroy()
      trigger.setAttribute('aria-expanded', 'false')
    })
  })
}
const unmount = scope => {
  for (const [root, dispose] of instances) {
    if (scope.contains(root)) {
      dispose()
      instances.delete(root)
    }
  }
}
mount(document)
window.addEventListener('pagehide', event => {
  if (!event.persisted) unmount(document)
})

CSS

assets/integration.css
.cms-overlay {
  position: fixed;
  inset: 0;
  z-index: 101;
  background: rgb(0 0 0 / 45%);
}
.cms-panel {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  padding: 1.5rem;
  max-height: 85dvh;
  background: #faf9fc;
  color: #24212b;
  border-radius: 1.5rem 1.5rem 0 0;
}
.cms-panel [data-drawer-body] {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cms-panel [data-drawer-title],
.cms-panel [data-drawer-handle],
.cms-panel [data-drawer-close] {
  flex-shrink: 0;
}
.cms-panel [data-drawer-title] {
  font-size: 1.5rem;
  margin: 1rem 0;
}
.cms-panel [data-drawer-close] {
  display: block;
  margin: 1rem 0 0 auto;
}
.cms-panel label {
  display: grid;
  gap: 0.75rem;
}
.cms-panel select,
.cms-panel button {
  font: inherit;
  padding: 0.75rem;
}

The plugin targets WordPress 6.3+ deferred-script arguments. The integration depends on the runtime handle, so asset order is explicit. Assets are queued for singular post content containing this shortcode; widgets, page builders or AJAX navigation require their own enqueue/mount policy. Labels and markup are static example content; escape dynamic PHP output and validate any submitted form data in a real integration. See wp_enqueue_script and frontend asset hooks.

Plain HTML

Use HTML / CDN with the same JavaScript API when a plain document is enough. Serving the pinned files yourself changes delivery, not the public namespace or lifecycle.

Ownership and accessible content

Framework state belongs in your application. Dialog DOM is disposable after close: retain form values in application state when they must survive reopening. Drawer owns modal focus, gestures and scroll locking; your component owns labels, validation, styling and teardown. See forms and non-modal examples and accessibility responsibilities.