Medium Modals
Set up
Import MediumModal, ModalButton, modalIdStor components and set variables in the script tag. To close a modal, use `closeModal` function in your event handler.
<script>
import { MediumModal, ModalButton } from "flowbite-svelte";
let modal1;
let modal2;
const handlebtnM1 = () => {
modal1.closeModal()
};
const handlebtnM2 = () => {
modal2.closeModal()
};
const handlebtnM3 = () => {
modal2.closeModal()
};
</script>
Examples
Create a button and modal.
<ModalButton id="modal1" btnName="Medium Modal" />
<MediumModal id="modal1" title="Basic Modal Title">
Basic Modal Content: Lorem ipsum dolor sit, amet consectetur adipisicing elit.
Ad odit aspernatur minus deserunt illo error eum temporibus officiis.
</MediumModal>
Medium modals with an action button
<ModalButton id="id1" btnName="Medium Modal with one action button" btnColor="gray" />
<MediumModal
bind:this={modal1}
id="id1"
btnColor="yellow"
title="Medium Modal Title"
btn1="Close"
on:handlebtn1={handlebtnM1}
>
Modal 2 Content: Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ad
odit aspernatur minus deserunt illo error eum temporibus officiis.
</MediumModal>
Medium modal with an action button
<ModalButton id="id2" btnName="Medium Modal with two action buttons" btnColor="blue" />
<MediumModal
bind:this={modal2}
id="id2"
btnColor="indigo"
title="Default Modal Title"
btn1="Go home"
btn2="Close"
on:handlebtn1={handlebtnM2}
on:handlebtn2={handlebtnM3}
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
</MediumModal>
Props
The component has the following props, type, and default values. See types page for type information.
ModalButton
Name | Type | Default |
---|---|---|
id | string | 'modal-id' |
btnName | string | 'Modal Name' |
btnColor | Colors | 'blue' |
MediumModal
Name | Type | Default |
---|---|---|
id | string | 'medium-modal' |
btnColor | Colors | 'blue' |
textColor | Colors | 'gray' |
title | string | 'Terms of Service' |
btn1 | string | |
btn2 | string |