Skip to content

Instantly share code, notes, and snippets.

@frippz
Last active March 26, 2024 11:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frippz/7bf61d50c708ad154052899d539a606a to your computer and use it in GitHub Desktop.
Save frippz/7bf61d50c708ad154052899d539a606a to your computer and use it in GitHub Desktop.
Native HTML dialog element in Svelte
<script>
export let dialog
</script>
<dialog bind:this={dialog} on:close>
<slot/>
</dialog>
<script>
import Dialog from './Dialog.svelte'
let dialog
</script>
<button on:click={() => dialog.showModal()}>Open modal</button>
<Dialog bind:dialog on:close={() => console.log('Modal closed')}>
<p>I love how easy this is! 😍</p>
</Dialog>
@frippz
Copy link
Author

frippz commented Mar 26, 2024

Found originally on DEV community and copied here because I can’t stand that website’s dick bars. 😜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment