🔥 隆重推出我們的新專案 t0ggles - 您終極的專案管理工具! 🔥

對話框 Vue 元件

對話框是一種模態視窗,會顯示在應用程式內容前方,以提供重要資訊,或提示使用者做出決定。

對話框元件

包含以下元件

  • 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

使 iOS 主題中的對話框背景半透明 (使用 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 主題中填滿,會覆寫 strongIosstrongMaterial布林值布林值

strongIos

使按鈕在 iOS 主題中變粗體布林值布林值

strongMaterial

使按鈕在 Material 主題中填滿

名稱說明
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 to
provide 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 to
provide 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-radio
component="div"
value="batman"
:checked="radioValue === 'batman'"
@change="() => (radioValue = 'batman')"
/>
</template>
</k-list-item>
<k-list-item label title="Spider-man">
<template #after>
<k-radio
component="div"
value="spiderman"
:checked="radioValue === 'spiderman'"
@change="() => (radioValue = 'spiderman')"
/>
</template>
</k-list-item>
<k-list-item label title="Hulk">
<template #after>
<k-radio
component="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>
MIT nolimits4web.