對話框是一種模態視窗,會顯示在應用程式內容前方,以提供重要資訊,或提示使用者做出決定。
包含以下元件
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 類別 | 布林值 | true | translucent |
backdrop-filter: blur
)名稱 | 類型 | 預設值 | 說明 |
---|---|---|---|
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 |
component | 字串 | iOS 主題中的文字顏色 | 元件的 HTML 元素 |
'button' | 布林值 | 布林值 | disabled |
使按鈕停用 | 布林值 | 布林值 | strong |
使按鈕在 iOS 主題中變粗體,並在 Material 主題中填滿,會覆寫 strongIos 和 strongMaterial | 布林值 | 布林值 | strongIos |
使按鈕在 iOS 主題中變粗體 | 布林值 | 布林值 | strongMaterial |
名稱 | 說明 |
---|---|
buttons | 對話框按鈕內容 |
content | 對話框主要內容 |
Material 主題的 Tailwind CSS 大小類別 | 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>