Files
heroui-vue/apps/docs/demos/modal-custom-trigger.vue
T

62 lines
1.9 KiB
Vue

<script setup lang="ts">
import {
Button,
Modal,
ModalBackdrop,
ModalBody,
ModalClose,
ModalCloseTrigger,
ModalContainer,
ModalDialog,
ModalFooter,
ModalHeader,
ModalHeading,
ModalIcon,
ModalTrigger,
} from "@heroui-vue/components";
import { IconSettings as Gear } from "@tabler/icons-vue";
</script>
<template>
<Modal>
<ModalTrigger
class="group flex items-center gap-3 rounded-2xl bg-surface p-4 shadow-xs select-none hover:bg-surface-secondary"
>
<div
class="flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-soft-foreground"
>
<Gear aria-hidden="true" class="size-6"></Gear>
</div>
<div class="flex flex-1 flex-col gap-0.5">
<p class="text-sm font-semibold">设置</p>
<p class="text-xs text-muted">管理你的偏好设置</p>
</div>
</ModalTrigger>
<ModalBackdrop>
<ModalContainer>
<ModalDialog class="sm:max-w-[360px]">
<ModalCloseTrigger></ModalCloseTrigger>
<ModalHeader>
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
<Gear aria-hidden="true" class="size-5"></Gear>
</ModalIcon>
<ModalHeading>设置</ModalHeading>
</ModalHeader>
<ModalBody>
<p>
使用
<code>Modal.Trigger</code>
可在标准按钮之外创建自定义触发器。此示例展示带图标与说明文字的卡片式触发器。
</p>
</ModalBody>
<ModalFooter>
<ModalClose as-child>
<Button variant="secondary">取消</Button>
</ModalClose>
<ModalClose as-child><Button>保存</Button></ModalClose>
</ModalFooter>
</ModalDialog>
</ModalContainer>
</ModalBackdrop>
</Modal>
</template>