UIkit3.x文档

模态对话框

创建具有各种样式并且带有过渡效果的模态对话框。

用法

模态组件由遮罩层、对话框和一个可选的关闭按钮组成。 您可以使用任何元素来切换模态对话框。 要启用必要的JavaScript,请添uk-toggle属性。<a>元素需要链接到模态对话框的ID。 如果您使用了其他元素(例如按钮),则只需添加uk-toggle="target: #ID"属性并链接到将模态对话框容器的ID。

uk-modal 性添加到<div>元素中,来创建模态对话框的容器和遮罩层,该遮罩层将遮挡整个页面。还必须添加一个id来指示用于切换的元素,使用以下class定义模态的各个控件。

Class Description
.uk-modal-dialog 将此类添加到子级的<div>元素创建对话框
.uk-modal-body 在模态对话框与内容之间创建padding。
.uk-modal-title 添加到标题元素以创建模态对话框的标题。
.uk-modal-close 添加到<a><button>元素创建关闭按钮。
<!-- This is a button toggling the modal -->
<button uk-toggle="target: #my-id" type="button"></button>

<!-- This is the modal -->
<div id="my-id" uk-modal>
    <div class="uk-modal-dialog uk-modal-body">
        <h2 class="uk-modal-title"></h2>
        <button class="uk-modal-close" type="button"></button>
    </div>
</div>
  • Open
  • <!-- This is a button toggling the modal -->
    <button class="uk-button uk-button-default uk-margin-small-right" type="button" uk-toggle="target: #modal-example">Open</button>
    
    <!-- This is an anchor toggling the modal -->
    <a href="#modal-example" uk-toggle>Open</a>
    
    <!-- This is the modal -->
    <div id="modal-example" uk-modal>
        <div class="uk-modal-dialog uk-modal-body">
            <h2 class="uk-modal-title">Headline</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
            <p class="uk-text-right">
                <button class="uk-button uk-button-default uk-modal-close" type="button">Cancel</button>
                <button class="uk-button uk-button-primary" type="button">Save</button>
            </p>
        </div>
    </div>

关闭按钮

要创建关闭按启用关闭功能,并为其添加适当的样式和设置定位,请将.uk-modal-close-default class 添加到 <a><button> 元素。要将关闭按钮放置在模态对话框外面,请添加.uk-modal-close-outside class。

添加Close 组件中的uk-close 属性以应用关闭图标。

<div id="my-id">
    <div class="uk-modal-dialog">
        <button class="uk-modal-close-default" type="button" uk-close></button>
    </div>
</div>

<div id="my-id">
    <div class="uk-modal-dialog">
        <button class="uk-modal-close-outside" type="button" uk-close></button>
    </div>
</div>
  • <!-- This is a button toggling the modal with the default close button -->
    <button class="uk-button uk-button-default uk-margin-small-right" type="button" uk-toggle="target: #modal-close-default">Default</button>
    
    <!-- This is the modal with the default close button -->
    <div id="modal-close-default" uk-modal>
        <div class="uk-modal-dialog uk-modal-body">
            <button class="uk-modal-close-default" type="button" uk-close></button>
            <h2 class="uk-modal-title">Default</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
    </div>
    
    <!-- This is a button toggling the modal with the outside close button -->
    <button class="uk-button uk-button-default uk-margin-small-right" type="button" uk-toggle="target: #modal-close-outside">Outside</button>
    
    <!-- This is the modal with the outside close button -->
    <div id="modal-close-outside" uk-modal>
        <div class="uk-modal-dialog uk-modal-body">
            <button class="uk-modal-close-outside" type="button" uk-close></button>
            <h2 class="uk-modal-title">Outside</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
    </div>

居中的模态对话框

要使模式对话框垂直居中,可以使用Margin 组件中的.uk-margin-auto-vertical class 。

<div class="uk-flex-top" uk-modal>
    <div class="uk-modal-dialog uk-margin-auto-vertical"></div>
</div>
  • Open
  • <a class="uk-button uk-button-default" href="#modal-center" uk-toggle>Open</a>
    
    <div id="modal-center" class="uk-flex-top" uk-modal>
        <div class="uk-modal-dialog uk-modal-body uk-margin-auto-vertical">
    
            <button class="uk-modal-close-default" type="button" uk-close></button>
    
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
        </div>
    </div>

Note .uk-flex-top需要 IE 11及以上支持 。


要将模态对话框分割为几个不同的内容部分,请使用以下class。

Class Description
.uk-modal-header 添加到<div> 元素以创建模态对话框的header。
.uk-modal-footer 添加到<div> 元素以创建模态对话框的footer.
<div id="my-id" uk-modal>
    <div class="uk-modal-dialog">
        <button class="uk-modal-close-default" type="button" uk-close></button>
        <div class="uk-modal-header">
            <h2 class="uk-modal-title"></h2>
        </div>
        <div class="uk-modal-body"></div>
        <div class="uk-modal-footer"></div>
    </div>
</div>
  • Open
  • <a class="uk-button uk-button-default" href="#modal-sections" uk-toggle>Open</a>
    
    <div id="modal-sections" uk-modal>
        <div class="uk-modal-dialog">
            <button class="uk-modal-close-default" type="button" uk-close></button>
            <div class="uk-modal-header">
                <h2 class="uk-modal-title">Modal Title</h2>
            </div>
            <div class="uk-modal-body">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
            </div>
            <div class="uk-modal-footer uk-text-right">
                <button class="uk-button uk-button-default uk-modal-close" type="button">Cancel</button>
                <button class="uk-button uk-button-primary" type="button">Save</button>
            </div>
        </div>
    </div>

容器宽度

添加.uk-modal-container class将模态对话框的宽度扩展到和Container的宽度相同。

<div id="my-id" class="uk-modal-container" uk-modal>...</div>
  • Open
  • <a class="uk-button uk-button-default" href="#modal-container" uk-toggle>Open</a>
    
    <div id="modal-container" class="uk-modal-container" uk-modal>
        <div class="uk-modal-dialog uk-modal-body">
            <button class="uk-modal-close-default" type="button" uk-close></button>
            <h2 class="uk-modal-title">Headline</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
    </div>

全屏幕

要创建填充满整个页面的模态对话框,请添加.uk-modal-full class。建议同时将 .uk-modal-close-full class添加到关闭按钮,以便它其适应其样式。

<div id="my-id" class="uk-modal-full" uk-modal>
    <div class="uk-modal-dialog">
        <button class="uk-modal-close-full uk-close-large" type="button" uk-close></button>
    </div>
</div>

使用gridwidth class,您可以创建一个漂亮的拆分全屏的模态对话框。

  • Open
  • <a class="uk-button uk-button-default" href="#modal-full" uk-toggle>Open</a>
    
    <div id="modal-full" class="uk-modal-full" uk-modal>
        <div class="uk-modal-dialog">
            <button class="uk-modal-close-full uk-close-large" type="button" uk-close></button>
            <div class="uk-grid-collapse uk-child-width-1-2@s uk-flex-middle" uk-grid>
                <div class="uk-background-cover" style="background-image: url('/skin/ukv3/images/photo.jpg');" uk-height-viewport></div>
                <div class="uk-padding-large">
                    <h1>Headline</h1>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
                </div>
            </div>
        </div>
    </div>

溢出

默认情况下,如果页面内容超过窗口高度,则该页面将和模态对话框一起滚动。要在模态中应用滚动条,请将Utility 组件中的uk-overflow-auto添加到模态对话框的body。

<div uk-modal>
    <div class="uk-modal-dialog" uk-overflow-auto></div>
</div>
  • <a class="uk-button uk-button-default" href="#modal-overflow" uk-toggle>Open</a>
    
    <div id="modal-overflow" uk-modal>
        <div class="uk-modal-dialog">
    
            <button class="uk-modal-close-default" type="button" uk-close></button>
    
            <div class="uk-modal-header">
                <h2 class="uk-modal-title">Headline</h2>
            </div>
    
            <div class="uk-modal-body" uk-overflow-auto>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
            </div>
    
            <div class="uk-modal-footer uk-text-right">
                <button class="uk-button uk-button-default uk-modal-close" type="button">Cancel</button>
                <button class="uk-button uk-button-primary" type="button">Save</button>
            </div>
    
        </div>
    </div>

媒体

如果要显示媒体,建议先看看Lightbox 组件是否能满足你的需要。您也可以使用模态对话框对标记进行更多控制,以便将媒体包裹在内。

Note 使用Video 组件中的uk-video属性可确保在关闭模态对话框的同时时停止视频播放。

<div uk-modal>
    <div class="uk-modal-dialog uk-width-auto">
        <iframe src="" uk-video></iframe>
    </div>
</div>
  • Image Video YouTube Vimeo

  •  <p uk-margin>
        <a class="uk-button uk-button-default" href="#modal-media-image" uk-toggle>Image</a>
        <a class="uk-button uk-button-default" href="#modal-media-video" uk-toggle>Video</a>
        <a class="uk-button uk-button-default" href="#modal-media-youtube" uk-toggle>YouTube</a>
        <a class="uk-button uk-button-default" href="#modal-media-vimeo" uk-toggle>Vimeo</a>
    </p>
    
    <div id="modal-media-image" class="uk-flex-top" uk-modal>
        <div class="uk-modal-dialog uk-width-auto uk-margin-auto-vertical">
            <button class="uk-modal-close-outside" type="button" uk-close></button>
            <img src="/skin/ukv3/images/photo.jpg" alt="">
        </div>
    </div>
    
    <div id="modal-media-video" class="uk-flex-top" uk-modal>
        <div class="uk-modal-dialog uk-width-auto uk-margin-auto-vertical">
            <button class="uk-modal-close-outside" type="button" uk-close></button>
            <video src="https://yootheme.com/site/images/media/yootheme-pro.mp4" controls playsinline uk-video></video>
        </div>
    </div>
    
    <div id="modal-media-youtube" class="uk-flex-top" uk-modal>
        <div class="uk-modal-dialog uk-width-auto uk-margin-auto-vertical">
            <button class="uk-modal-close-outside" type="button" uk-close></button>
            <iframe src="https://www.youtube-nocookie.com/embed/c2pz2mlSfXA" width="1920" height="1080" frameborder="0" uk-video></iframe>
        </div>
    </div>
    
    <div id="modal-media-vimeo" class="uk-flex-top" uk-modal>
        <div class="uk-modal-dialog uk-width-auto uk-margin-auto-vertical">
            <button class="uk-modal-close-outside" type="button" uk-close></button>
            <iframe src="https://player.vimeo.com/video/1084537" width="500" height="281" frameborder="0" uk-video></iframe>
        </div>
    </div>

模态组

您可以从一个模态框链接到另一个模态框,然后再链接到另一个模态框。使用这个选项可以在模态框中创建多步骤引导这样的形式。

<div id="modal-group-1" uk-modal>
    <div class="uk-modal-dialog">
        <a href="#modal-group-2" uk-toggle>Next</a>
    </div>
</div>

<div id="modal-group-2" uk-modal>
    <div class="uk-modal-dialog">
        <a href="#modal-group-1" uk-toggle>Previous</a>
    </div>
</div>
  • Modal 1 Modal 2

  • <p uk-margin>
        <a class="uk-button uk-button-default" href="#modal-group-1" uk-toggle>Modal 1</a>
        <a class="uk-button uk-button-default" href="#modal-group-2" uk-toggle>Modal 2</a>
    </p>
    
    <div id="modal-group-1" uk-modal>
        <div class="uk-modal-dialog">
            <button class="uk-modal-close-default" type="button" uk-close></button>
            <div class="uk-modal-header">
                <h2 class="uk-modal-title">Headline 1</h2>
            </div>
            <div class="uk-modal-body">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
            </div>
            <div class="uk-modal-footer uk-text-right">
                <button class="uk-button uk-button-default uk-modal-close" type="button">Cancel</button>
                <a href="#modal-group-2" class="uk-button uk-button-primary" uk-toggle>Next</a>
            </div>
        </div>
    </div>
    
    <div id="modal-group-2" uk-modal>
        <div class="uk-modal-dialog">
            <button class="uk-modal-close-default" type="button" uk-close></button>
            <div class="uk-modal-header">
                <h2 class="uk-modal-title">Headline 2</h2>
            </div>
            <div class="uk-modal-body">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
            </div>
            <div class="uk-modal-footer uk-text-right">
                <button class="uk-button uk-button-default uk-modal-close" type="button">Cancel</button>
                <a href="#modal-group-1" class="uk-button uk-button-primary" uk-toggle>Previous</a>
            </div>
        </div>
    </div>

组件选项

以下选项中的任何一个都可以应用于组件属性,多个选项之间用分号分隔。了解更多

Option Value Default Description
esc-close Boolean true 按下Esc 键时关闭模态框。
bg-close Boolean true 单击背景时关闭模态框。
stack Boolean false 当打开多个模块时,堆叠模态框。默认情况下,前一个模态框会被后一个遮住。
container String true 通过选择器定义一个目标容器,以指定模态框应附加到DOM中的位置。将其设置为false 将阻止此行为。
cls-page String 'uk-modal-page' 当modal处于激活状态时要添加到<body> 的class。
cls-panel String 'uk-modal-dialog' 被视为模态面板的元件类别
sel-close String '.uk-modal-close, .uk-modal-close-default, .uk-modal-close-outside, .uk-modal-close-full' 应该触发模态对话框关闭的元素的CSS选择器

JavaScript

了解更多有关JavaScript 组件的信息。

初始化

UIkit.modal(element, options);

事件

附加此组件的元素将触发以下事件:

Name Description
beforeshow 元素显示前触发。
show 元素显示后触发
shown 元素的显示动画完成后触发。
beforehide 隐藏元素之前触发。
hide 隐藏元素动画开始后触发。
hidden 元素被隐藏后触发。

方法

以下方法可用于该组件:

Show

UIkit.modal(element).show();

显示模态框。

Hide

UIkit.modal(element).hide();

隐藏模态框


组件附带了许多准备好的模态对话框,您可以使用它们进行用户交互。您可以直接从JavaScript调用对话框,并使用回调函数处理用户输入。

Code Description
UIkit.modal.alert('UIkit alert!') 显示带有一个按钮的警报框。
UIkit.modal.confirm('UIkit confirm!') 显示一个带有消息和两个按钮的确认对话框。
UIkit.modal.prompt('Name:', 'Your name') 显示一个文本输入对话框。
UIkit.modal.dialog('<p>UIkit dialog!</p>'); 显示带有HTML内容的对话框。

为了处理用户输入,模态框使用基于promise的接口,该接口提供一个then()函数来注册您的回调函数。UIkit.modal.dialog函数将返回模态本身。

UIkit.modal.confirm('UIkit confirm!').then(function() {
    console.log('Confirmed.')
}, function () {
    console.log('Rejected.')
});

返回的 promise 有一个属性dialog,它包含对模式本身的引用。这让您可以操纵例如模态元素的标记等。

const modal = UIkit.modal.confirm('UIkit confirm!').dialog; // The modal component
const el = modal.$el; // The modal element
  • Dialog Alert Confirm Prompt

  • <p uk-margin>
    
        <a id="js-modal-dialog" class="uk-button uk-button-default" href="#">Dialog</a>
    
        <a id="js-modal-alert" class="uk-button uk-button-default" href="#">Alert</a>
    
        <a id="js-modal-confirm" class="uk-button uk-button-default" href="#">Confirm</a>
    
        <a id="js-modal-prompt" class="uk-button uk-button-default" href="#">Prompt</a>
    
        <script>
    
           UIkit.util.on('#js-modal-dialog', 'click', function (e) {
               e.preventDefault();
               e.target.blur();
               UIkit.modal.dialog('<p class="uk-modal-body">UIkit dialog!</p>');
           });
    
           UIkit.util.on('#js-modal-alert', 'click', function (e) {
               e.preventDefault();
               e.target.blur();
               UIkit.modal.alert('UIkit alert!').then(function () {
                   console.log('Alert closed.')
               });
           });
    
           UIkit.util.on('#js-modal-confirm', 'click', function (e) {
               e.preventDefault();
               e.target.blur();
               UIkit.modal.confirm('UIkit confirm!').then(function () {
                   console.log('Confirmed.')
               }, function () {
                   console.log('Rejected.')
               });
           });
    
           UIkit.util.on('#js-modal-prompt', 'click', function (e) {
               e.preventDefault();
               e.target.blur();
               UIkit.modal.prompt('Name:', 'Your name').then(function (name) {
                   console.log('Prompted:', name)
               });
           });
    
        </script>
    
    </p>