Skip to main content

BwOverlay | bw-overlay

Overview​

Overlays display content in a floating container with a backdrop. They can be configured to show as a modal, drawer, or bottom sheet. The container has no base styling; you should use bw-view to format the overlay's content.

Usage​

Close Buttons​

When using a bw-view with the overlay component, it will automatically add a close button for the overlay. If you wish to add more close buttons, or you are not using a bw-view, add data-overlay="close" as an attribute to the desired close button. If the close button needs to show a discard changes prompt for a specific form, set the data-discard-form attribute equal to the id of the form.

<bw-overlay>
<bw-button slot="trigger">Open Modal</bw-button>
<bw-view label="Example Modal">
<bw-form id="closeButtonExampleForm">
<bw-input></bw-input>
</bw-form>
<bw-button data-overlay="close" slot="footer">Cancel (No Discard)</bw-button>
<bw-button data-overlay="close" data-discard-form="closeButtonExampleForm" slot="footer">Cancel (Discard)</bw-button>
</bw-view>
</bw-overlay>

Drawers and Bottom Sheets​

You can set the side attribute to left or right to present the overlay as drawer, or bottom for a bottom sheet.

<bw-overlay side="left">
<bw-button slot="trigger">Open Drawer</bw-button>
<bw-view label="Example Drawer">
<p>Hello there</p>
</bw-view>
</bw-overlay>
<bw-overlay side="bottom">
<bw-button slot="trigger">Open Sheet</bw-button>
<bw-view label="Example Bottom Sheet">
<p>Hello there</p>
</bw-view>
</bw-overlay>

Bottom sheets snap to 40% and 80% of the screen height. If you drag it near the bottom or swipe down, it will auto dismiss.

Modals​

By default, overlay will appear centered in the middle of the screen. This is referred to as a modal

<bw-overlay>
<bw-button slot="trigger">Open Modal</bw-button>
<bw-view label="Example Modal">
<p>Hello there</p>
</bw-view>
</bw-overlay>

When being used as a modal, you can set the size attribute to change the dimensions of the overlay.

<bw-overlay id="overlaySizeEx" size="md">
<bw-button slot="trigger">Open Modal</bw-button>
<bw-view label="Example Modal">
<bw-radio-group id="overlaySizeControl" value="md">
<bw-radio-button value="xs">XS</bw-radio-button>
<bw-radio-button value="sm">SM</bw-radio-button>
<bw-radio-button value="md">MD</bw-radio-button>
<bw-radio-button value="lg">LG</bw-radio-button>
<bw-radio-button value="xl">XL</bw-radio-button>
</bw-radio-group>
</bw-view>
</bw-overlay>

<script>
const radioGroup = document.querySelector('#overlaySizeControl')
const overlay = document.querySelector('#overlaySizeEx')
radioGroup.addEventListener('valueChange', ({detail}) => {
overlay.size = detail
})
</script>

Properties​

PropertyAttributeDescriptionTypeDefault
backdropDismissbackdrop-dismissBackdrop will close the overlay on click when enabledbooleantrue
destroy--Execute a callback after the overlay has dismissed() => void | Promise<void>undefined
init--Execute a callback before the overlay starts presenting() => void | Promise<void>undefined
openopenOpens and closes overalybooleanfalse
sidesideSide of the screen where the drawer will be displayed"bottom" | "left" | "right"undefined
sizesizeSize of the overlay"lg" | "md" | "sm" | "xl" | "xs""md"

Events​

EventDescriptionType
overlayDismissEmits whenever the overlay has finished closing. Emits the role and optional data object passed to the dismiss() method.CustomEvent<T>
overlayPresentEmits whenever the overlay has opened. Does not emit any dataCustomEvent<any>

Methods​

dismiss(role?: string, data?: any) => Promise<void>​

Dismisses the modal

Parameters​

NameTypeDescription
rolestring- The role of the modal
dataany- The data of the modal

Returns​

Type: Promise<void>

present() => Promise<void>​

Presents the modal

Returns​

Type: Promise<void>

Slots​

SlotDescription
The default slot
"trigger"The trigger for the overlay

Shadow Parts​

PartDescription
"dialog"The dialog element of the modal
"inner-container"The inner container of the dialog element

CSS Custom Properties​

NameDescription
--backgroundThe background color of the modal
--borderThe border of the modal
--colorThe color of the modal
--radiusThe radius of the modal

Dependencies​

Used by​

Depends on​

Graph​


© 2026 United Systems & Software - All Rights Reserved.