Skip to main content

Modal

Add dialogs to your site for lightboxes, user notifications, or completely custom content.

Live demo#

Toggle a working modal demo by clicking the button below. It will slide down and fade in from the top of the page.

Launch demo modal
Modal Title

ModalBody text goes here.

CloseSave changes

    <uxf-button variant="primary" onClick="openModal()">Launch demo modal</uxf-button>
    <uxf-modal id="modal" show={show} closeModal={closeModal}>        <div slot="header">            <h5>Modal Title</h5>            <uxf-close-button/>        </div>        <div slot="body">            <p>ModalBody text goes here.</p>        </div>        <div slot="footer">            <uxf-button onClick={closeModal} variant="secondary">Close</uxf-button>            <uxf-button variant="primary">Save changes</uxf-button>        </div>    </uxf-modal>    <script>        const openModal = () => {            const modal = document.querySelector(`#modal`)            modal.show = true;        };            const closeModal = () => {            const modal = document.querySelector(`#modal`)            modal.show = false;        };    </script>

Static backdrop#

When backdrop is set to static, the modal will not close when clicking outside it. Click the button below to try it.

Launch static backdrop modal
Modal Title

ModalBody text goes here.

CloseSave changes

    <uxf-button variant="primary" onClick="openModal()">Launch static backdrop modal</uxf-button>
    <uxf-modal id="modal" show={show} closeModal={closeModal} backdrop="static" keyboard="false">        <div slot="header">            <h5>Modal Title</h5>            <uxf-close-button/>        </div>        <div slot="body">            <p>ModalBody text goes here.</p>        </div>        <div slot="footer">            <uxf-button onClick={closeModal} variant="secondary">Close</uxf-button>            <uxf-button variant="primary">Save changes</uxf-button>        </div>    </uxf-modal>    <script>        const openModal = () => {            const modal = document.querySelector(`#modal`)            modal.show = true;        };            const closeModal = () => {            const modal = document.querySelector(`#modal`)            modal.show = false;        };    </script>

Fullscreen Modal#

You can use the fullscreen prop to make the modal fullscreen. Specifying a breakpoint will only set the modal as fullscreen below the breakpoint size.

Full screenFull screenbelow smFull screenbelow mdFull screenbelow lgFull screenbelow xlFull screenbelow xxl
Modal Title

ModalBody text goes here.

CloseSave changes

    <uxf-button variant="primary" onClick="openModal()">Launch fullscreen modal</uxf-button>
    <uxf-modal id="modal" show={show} closeModal={closeModal} fullscreen>        <div slot="header">            <h5>Modal Title</h5>            <uxf-close-button/>        </div>        <div slot="body">            <p>ModalBody text goes here.</p>        </div>        <div slot="footer">            <uxf-button onClick={closeModal} variant="secondary">Close</uxf-button>            <uxf-button variant="primary">Save changes</uxf-button>        </div>    </uxf-modal>    <script>        const openModal = () => {            const modal = document.querySelector(`#modal`)            modal.show = true;        };            const closeModal = () => {            const modal = document.querySelector(`#modal`)            modal.show = false;        };    </script>

Scrolling long content#

When modals become too long for the user’s viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean.

Launch scrollable modal
Modal Title

This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.

This content should appear at the bottom after you scroll.

CloseSave changes

    <uxf-button variant="primary" onClick="openModal()">Launch scrollable modal</uxf-button>
    <uxf-modal id="modal" show={show} closeModal={closeModal} scrollable>        <div slot="header">            <h5>Modal Title</h5>            <uxf-close-button/>        </div>        <div slot="body">            <p style="height: 1200px">This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.</p>            <p>ModalBody text goes here.</p>        </div>        <div slot="footer">            <uxf-button onClick={closeModal} variant="secondary">Close</uxf-button>            <uxf-button variant="primary">Save changes</uxf-button>        </div>    </uxf-modal>    <script>        const openModal = () => {            const modal = document.querySelector(`#modal`)            modal.show = true;        };            const closeModal = () => {            const modal = document.querySelector(`#modal`)            modal.show = false;        };    </script>

Properties#

PropertyAttributeDescriptionTypeDefault
backdropbackdropboolean \| stringtrue
centeredcenteredbooleanfalse
fadefadebooleantrue
fullscreenfullscreenboolean \| stringundefined
keyboardkeyboardbooleantrue
modalFocusmodal-focusbooleantrue
scrollablescrollablebooleanfalse
showshowbooleanfalse
sizesizestring"none"

Events#

EventDescriptionType
closeModalCustomEvent<any>
openModalCustomEvent<any>