Modal

The <Modal> component is used to display an interactive modal dialog.

Properties

Name
Default
Description
show
false
If true, the modal will be displayed.
title
The title of the modal.
size
medium
The size of the modal.
  • small
  • medium
  • large
closeOnOutsideClick
true
Whether to close the modal when clicking outside of it.
closeOnEscape
true
Whether to close the modal when pressing the escape key.

Slots

Name
Description
default
The content/body of the modal.
title
Override the title property of the modal.
footer
The footer of the modal.

Examples

Basic Modal

<script>
    import { Modal, Button } from '@hyvor/design/components';
    let show = false;
</script>

<Button on:click={() => show = true}>Show modal</Button>

<Modal title="Confirm to delete" bind:show={show}>

    Please confirm that you want to delete this item. This action cannot be undone.

    <div slot="footer">
        <Button variant="invisible" on:click={() => show = false}>Cancel</Button>
        <Button color="red">Delete</Button>
    </div>

</Modal>

Sizes

Set the size attribute to small, medium or large to change the size of the modal.

Title Slot

You can use the title slot to customize the title of the modal.

<Modal bind:show={show} size="large">

    <TabNav active="paste" slot="title">
        <TabNavItem name="paste">
            <IconLink45deg slot="start" />
            Paste Link
        </TabNavItem>
        <TabNavItem name="posts">
            <IconSearch slot="start" />
            Search Posts
        </TabNavItem>
    </TabNav>

    This is a modal with a tab navigation in the title.

    <div slot="footer">
        <Button variant="invisible" on:click={() => show5 = false}>Close</Button>
    </div>

</Modal>
Table of Contents