Skip to content

BeeModal ​

A centered dialog that blocks the page behind it. Keyboard focus stays inside, Escape closes it, and focus returns to the button that opened it.

ts
import { BeeModal } from "@thaisrr/beedesign";
import "@thaisrr/beedesign/style.css";

Usage ​

Opening is controlled with v-model:open. The title is required: it appears in the header and serves as the dialog's accessible name. Content goes in the default slot.

Width ​

The width prop accepts any CSS width. The default value, min(90vw, var(--bd-overlay-width)) (448 px by default), keeps a margin on mobile.

Hidden title ​

With hide-title, the title is no longer visible but is still announced by screen readers. It is useful when the display is self-explanatory, such as a navigation menu.

Returning focus ​

On closing, focus automatically returns to the element that had it on opening, usually the trigger button. If the trigger is no longer on the page or must be another element, pass it with return-focus-el.

API ​

Props ​

NameTypeDefaultDescription
titlestringTitle and accessible name of the modal. Required.
openbooleanOpen state, to use with v-model:open. Required.
widthstring"min(90vw, 418px)"CSS width of the modal.
hideTitlebooleanfalseHides the title visually, keeps it for screen readers.
closeLabelstring"Close"Accessible text of the close button.
returnFocusElHTMLElement | nullnullElement that gets the focus back on closing.
panelIdstringgeneratedId of the panel, for an external aria-controls.

To localize it, pass the text of your language, for example close-label="Fermer".

Events ​

NamePayloadDescription
update:openbooleanEmitted with false on click on the backdrop, on the close button, or on Escape.

Slots ​

NameDescription
defaultContent of the modal.

CSS variables used ​

--bd-color-overlay, --bd-z-modal, --bd-color-surface, --bd-color-border, --bd-color-text, --bd-color-primary-light, --bd-color-primary-medium, --bd-color-primary-dark, --bd-color-focus, --bd-font-main, --bd-font-title, --bd-font-size-lg, --bd-radius-md, --bd-radius-full, --bd-space-md, --bd-shadow-3, --bd-transition-fast, --bd-transition-base, --bd-border-width, --bd-close-size, --bd-overlay-width, --bd-focus-ring-width, --bd-focus-ring-width, --bd-focus-ring-offset.

Accessibility ​

  • role="dialog" and aria-modal="true", named by its title.
  • Focus moves to the close button on opening, and Tab and Shift+Tab loop inside the modal.
  • Escape closes the modal, and focus is given back on closing.
  • Page scrolling is locked while the modal is open.
  • Transitions are disabled when prefers-reduced-motion is enabled.