对话框是一种出现在应用程序内容前面的模态窗口,用于提供关键信息或提示做出决定。
包含以下组件
Dialog
- 对话框元素DialogButton
- 对话框按钮元素名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
backdrop | 布尔值 | true | 启用弹出式背景(弹出式后面半透明的暗层) |
buttons | 字符串 | 对话框按钮内容 | |
colors | 对象 | 包含 Tailwind CSS 颜色类的对象 | |
colors.bgIos | 字符串 | 'bg-white dark:bg-neutral-800' | iOS 主题中的对话框背景颜色 |
colors.bgMaterial | 字符串 | 'bg-md-light-surface-3 dark:bg-md-dark-surface-3' | iOS 主题中的对话框背景颜色 |
colors.contentTextIos | 字符串 | '' | iOS 主题中的内容文本颜色 |
colors.contentTextMaterial | 字符串 | 'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant' | Material 主题中的内容文本颜色 |
colors.titleIos | 字符串 | '' | iOS 主题中的标题文本颜色 |
colors.titleMaterial | 字符串 | 'text-md-light-on-surface dark:text-md-dark-on-surface' | Material 主题中的标题文本颜色 |
component | 字符串 | 'div' | 组件的 HTML 元素 |
content | 字符串 | 对话框主要内容 | |
opened | 布尔值 | false | 允许打开/关闭弹出式窗口并设置其初始状态 |
sizeIos | 字符串 | 'w-[16.875rem]' | iOS 主题的 Tailwind CSS 大小类 |
sizeMaterial | 字符串 | 'w-[19.5rem]' | Material 主题的 Tailwind CSS 大小类 |
title | 字符串 | 对话框标题内容 | |
titleFontSizeIos | 字符串 | 'text-[18px]' | iOS 主题的标题字体大小的 Tailwind CSS 类 |
titleFontSizeMaterial | 字符串 | 'text-[24px]' | Material 主题的标题字体大小的 Tailwind CSS 类 |
translucent | 布尔值 | true | 在 iOS 主题中使对话框背景半透明(使用 |
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
colors | 对象 | 包含 Tailwind CSS 颜色类的对象 | |
colors.activeBgIos | 字符串 | 'active:bg-black active:bg-opacity-10 dark:active:bg-white dark:active:bg-opacity-10' | iOS 主题中活动/按下状态的背景颜色 |
colors.disabledTextIos | 字符串 | 'text-black text-opacity-30 dark:text-white dark:text-opacity-30' | iOS 主题中禁用按钮的文本颜色 |
colors.textIos | 字符串 | ''text-primary | iOS 主题中的文本颜色 |
component | 字符串 | 'button' | 组件的 HTML 元素 |
disabled | 布尔值 | false | 使按钮禁用 |
strong | 布尔值 | false | 使按钮在 iOS 主题中变为粗体,在 Material 主题中变为填充,覆盖 |
strongIos | 布尔值 | false | 使按钮在 iOS 主题中变为粗体 |
strongMaterial | 布尔值 | false | 使按钮在 Material 主题中变为填充 |
名称 | 描述 |
---|---|
buttons | 对话框按钮内容 |
content | 对话框主要内容 |
title | 对话框标题内容 |
<template><k-page><k-navbar title="Dialog" /><k-block strong inset class="space-y-4"><p>Dialog is a type of modal window that appears in front of app content toprovide critical information, or prompt for a decision to be made.</p></k-block><k-block strong inset><p class="grid grid-cols-2 md:grid-cols-4 gap-4"><k-button rounded @click="() => (basicOpened = true)">Basic</k-button><k-button rounded @click="() => (alertOpened = true)">Alert</k-button><k-button rounded @click="() => (confirmOpened = true)">Confirm</k-button><k-button rounded @click="() => (listOpened = true)">List</k-button></p></k-block><k-dialog:opened="basicOpened"@backdropclick="() => (basicOpened = false)"><template #title>Dialog Title</template>Dialog is a type of modal window that appears in front of app content toprovide critical information, or prompt for a decision to be made.<template #buttons><k-dialog-button @click="() => (basicOpened = false)">Action 2</k-dialog-button><k-dialog-button @click="() => (basicOpened = false)">Action 1</k-dialog-button></template></k-dialog><k-dialog:opened="alertOpened"@backdropclick="() => (alertOpened = false)"><template #title>Konsta UI</template>Hello world!<template #buttons><k-dialog-button @click="() => (alertOpened = false)">Ok</k-dialog-button></template></k-dialog><k-dialog:opened="confirmOpened"@backdropclick="() => (confirmOpened = false)"><template #title>Konsta UI</template>All good today?<template #buttons><k-dialog-button @click="() => (confirmOpened = false)">No</k-dialog-button><k-dialog-button strong @click="() => (confirmOpened = false)">Yes</k-dialog-button></template></k-dialog><k-dialog :opened="listOpened" @backdropclick="() => (listOpened = false)"><template #title>Your super hero</template><k-list nested class="-mx-4"><k-list-item label title="Batman"><template #after><k-radiocomponent="div"value="batman":checked="radioValue === 'batman'"@change="() => (radioValue = 'batman')"/></template></k-list-item><k-list-item label title="Spider-man"><template #after><k-radiocomponent="div"value="spiderman":checked="radioValue === 'spiderman'"@change="() => (radioValue = 'spiderman')"/></template></k-list-item><k-list-item label title="Hulk"><template #after><k-radiocomponent="div"value="hulk":checked="radioValue === 'hulk'"@change="() => (radioValue = 'hulk')"/></template></k-list-item></k-list><template #buttons><k-dialog-button @click="() => (listOpened = false)">Confirm</k-dialog-button></template></k-dialog></k-page></template><script>import { ref } from 'vue';import {kPage,kNavbar,kNavbarBackLink,kBlock,kButton,kDialog,kDialogButton,kList,kListItem,kRadio,} from 'konsta/vue';export default {components: {kPage,kNavbar,kNavbarBackLink,kBlock,kButton,kDialog,kDialogButton,kList,kListItem,kRadio,},setup() {const basicOpened = ref(false);const alertOpened = ref(false);const confirmOpened = ref(false);const listOpened = ref(false);const radioValue = ref('batman');return {basicOpened,alertOpened,confirmOpened,listOpened,radioValue,};},};</script>