Sample optional panel
This is secondary detail that can be dismissed.
A close button dismisses its current surface. It is not a delete, cancel-save or discard action unless the product explicitly defines and explains that effect. Use a native button with a clear name and a generous hit area. An × glyph alone is not a useful accessible name.
Fictitious local panel and native dialog. Closing does not delete data or save changes.
This is secondary detail that can be dismissed.
Disabled specimen:
The optional local panel starts visible. Dismissing it removes the panel and moves focus to Restore sample panel; restoring mounts it again without moving focus. Open sample dialog uses native showModal. Its close button or Escape closes it, and focus returns to the opener. The disabled close specimen is noninteractive. There is no remote save, deletion or data loss. All sample content is fictitious.
CloseButtonUsageDemo.vue has no props or emits. visible starts true. dismiss() sets it false then focuses Restore after the DOM update. The button sets it true again. open() calls the dialog ref's showModal; closed() returns focus to the opener on its close event. The disabled specimen has native disabled. The labelled dialog title uses a guide-specific ID; scope it per instance before mounting multiple copies.
<script setup>
import CloseButtonUsageDemo from './.vitepress/theme/CloseButtonUsageDemo.vue'
</script>
<template><CloseButtonUsageDemo /></template>No timers, global listeners, storage or requests exist, so unmount needs no cleanup. This is not an installed CloseButton prop/event API. A host could provide { label, disabled, onClose }, but close effects and focus belong to that surface, not a universal glyph controller.
| State/context | Actual behavior or integration rule |
|---|---|
| Default/hover/pressed/focus | Native button, 44px minimum area, visible focus ring and restrained feedback. |
| Disabled | Native disabled prevents activation and removes normal Tab stop. Provide a reason nearby when this matters in the host. |
| Inline panel | Removes local content, focus to Restore. No Escape handler. |
| Modal dialog | Native modal behavior, explicit close and Escape, return to opener. No outside-click dismissal implemented. |
| Toast | Use per-item dismiss ID and clear its timer. See Toasts; a close action must not remove unrelated messages. |
| Offcanvas | Use that surface's modal/nonmodal and focus policy. See Offcanvas, not a shared assumption that every side panel is modal. |
| Source | Actual implementation and limits |
|---|---|
| UI kit, Components, Lustro guide | The existing Close sample panel button calls showToast('Sample panel closed'); it demonstrates acknowledgement, not removal of the displayed panel. Its name does not prove a panel was actually dismissed. |
That catalog feedback shares the local toast timer system. This guide's actual panel removal and native-dialog example teach integration without silently changing the existing specimen or claiming a universal installed API.
Guide hover background changes over 140ms and press scales to 96% over 120ms. Panel/dialog entrances fade and move 4px over 160ms. Reduced motion removes all transitions/entrances. Closing is immediate with no delayed exit or focus transfer. Native Enter/Space activates the button. The glyph is aria-hidden, and the accessible name names the surface.
Test panel dismiss/restore, disabled behavior, dialog close/Escape, focus return, keyboard, hit area, reduced motion and narrow wrapping. Test real unsaved-content policies in the host before wiring close to navigation or disposal. Do not report a save, cancellation or deletion from a close animation alone.
Open a detail panel without losing the page behind it. This shared pattern follows the current template's colors. Fictitious data; actions stay local.