Example
The example below displays a red square when the modal is opened. The modal can be closed by
clicking anywhere outside of the square or pressing the Esc key. While it is open, the
background will not scroll and elements outside of the modal cannot be focused.
1
2
3
4
5
6
7
8
9
10
11
12
13<Button on:click={() => (open = true)}>Open Modal</Button>
<Modal bind:open>
<div />
</Modal>
<style>
div {
background: red;
height: 100px;
width: 100px;
}
</style>