I'm new to Magento 2. For homepage popup i have added below code

<div id="popup-modal">
        Test Data

        require(['jquery', 'Magento_Ui/js/modal/modal'], function ($, modal) {
            var options = {
                type: 'popup',
                responsive: true,
                innerScroll: true,

            var popup = modal(options, $('#popup-modal'));


It's not showing in center, as well how to set height & width of modal. Can we make auto as per content? enter image description here


Just change or overwrite following style

.modal-popup._show .modal-inner-wrap {
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    margin: auto;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.