Extra-large Modals
Set up
Import ExtraLargeModal and ModalButton components and set variables in the script tag. To close a modal, use `closeModal` function in your event handler.
<script>
import { ModalButton, ExtraLargeModal }from '$lib/index';
let modal2;
let modal3;
const handlebtn1 = () => {
alert("handlebtn1 is clicked from a parent page.");
modal2.closeModal()
};
const handlebtn2 = () => {
alert("handlebtn2 is clicked from a parent page.");
modal3.closeModal()
};
const handlebtn3 = () => {
alert("handlebtn3 is clicked from a parent page.");
modal3.closeModal()
};
</script>
Examples
Create a button and modal.
<script>
import { ModalButton, ExtraLargeModal } from "flowbite-svelte";
</script>
<ModalButton id="exm1" btnName="Info Modal" />
<ExtraLargeModal id="exm1" title="Info Modal">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
</ExtraLargeModal>
Extra-large modals with on button
Create a button and modal.
<script>
import { ModalButton, ExtraLargeModal } from "flowbite-svelte";
let modal2;
const handlebtn1 = () => {
alert("handlebtn1 is clicked from a parent page.");
extraLargModal.closeModal()
};
</script>
<ModalButton id="id1" btnName="Extra Large Modal with one button" btnColor="green" />
<ExtraLargeModal
bind:this={modal2}
id="id1"
title="Default Modal Title"
btn1="Go home"
on:handlebtn1={handlebtn1}
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
</ExtraLargeModal>
Extra-large modal with two buttons
Create a button and modal.
<ModalButton id="id2" btnName="Extra Large Modal with two buttons" btnColor="purple" />
<ExtraLargeModal
bind:this={modal3}
id="id2"
btnColor="indigo"
title="Default Modal Title"
btn1="Go home"
btn2="Close"
on:handlebtn1={handlebtn2}
on:handlebtn2={handlebtn3}
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
</ExtraLargeModal>
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' |
ExtraLargeModal
Name | Type | Default |
---|---|---|
id | string | 'extralarge-modal' |
btnColor | Colors | 'blue' |
textColor | Colors | 'gray' |
title | string | 'Terms of Service' |
btn1 | string | |
btn2 | string |