Sign In

@daflow-ui/ui-dialog

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daflow-ui/ui-dialog

Dialog component for DaFlow UI

latest
npmnpm
Version
0.1.2
Version published
Weekly downloads
9
50%
Maintainers
2
Weekly downloads
 
Created
Source

@daflow-ui/ui-dialog

Dialog component for DaFlow UI.

Installation

pnpm add @daflow-ui/ui-dialog

Usage

全局引入样式(在 main.ts 中):

import '@daflow-ui/ui-dialog/style.css';

在组件中使用:

<script setup lang="ts">
import { ref } from 'vue';
import { DfDialog } from '@daflow-ui/ui-dialog';

const open = ref(false);
</script>

<template>
  <button @click="open = true">
    打开对话框
  </button>

  <DfDialog v-model="open" title="基础对话框">
    <p>这是对话框的主体内容。</p>

    <template #footer>
      <button @click="open = false">
        关闭
      </button>
    </template>
  </DfDialog>
</template>

Props

PropTypeDefaultDescription
modelValuebooleanfalse控制显示/隐藏
titlestring标题文字;存在 header slot 时不生效
idstring自动生成Dialog 根 id;只接受字母、数字、-_;非法值会在开发环境告警,并回退到内部生成的安全 id
idsPartial<DialogIds>自动生成覆盖 trigger / content / positioner / backdrop / title / description / closeTrigger 的最终 DOM id;各项只接受字母、数字、-_,非法值会回退到默认派生 id
widthstring | number'640px'宽度,传 number 自动加 px
fullscreenbooleanfalse是否以全屏布局渲染 Dialog
destroyOnClosebooleanfalse关闭后销毁内容 DOM,下次打开重新挂载
closeOnBackdropClickbooleantrue点击遮罩是否关闭
closeOnEscapebooleantrueESC 是否关闭
restoreFocusbooleantrue关闭时是否恢复焦点到打开前的元素
initialFocusEl() => HTMLElement | null指定 Dialog 打开时的初始焦点元素
finalFocusEl() => HTMLElement | null自动回退指定 Dialog 关闭时的返回焦点元素;未传时优先回退到打开前缓存的 activeElement
showClosebooleantrue是否显示右上角关闭按钮;存在 header slot 时不生效
beforeClose() => void | boolean | Promise<void | boolean>关闭前拦截,显式返回 false 阻止关闭

Emits

EventPayloadDescription
update:modelValuebooleanv-model 同步
open开始打开时触发
opened打开动画结束后触发
close开始关闭时触发
closed关闭动画结束后触发

Slots

SlotDescription
default主体内容区,内容过长时 body 区域自动滚动
header自定义头部,完全替换默认头部结构;title、内置关闭按钮和默认头部内边距都不会保留
footer底部操作区,内置布局与间距,不含预置按钮

Notes

  • 始终 Teleport 到 body
  • 遮罩始终存在,不暴露 modal 开关
  • body scroll 锁定由 Ark UI 处理
  • class 会透传到 content 根节点
  • body-inner 是内部布局用 data-part,当前不作为公开 selector contract 承诺
  • 默认会生成不含冒号的安全 ids;显式传入的 id / ids 不会被静默改写,非法值会在开发环境告警并回退到安全默认值
  • 如需稳定控制打开/关闭时的焦点行为,优先使用 initialFocusElfinalFocusEl

Development

Install dependencies

pnpm install

Start playground (at monorepo root)

cd ../..
pnpm dev

Build

pnpm build

Type check

pnpm typecheck

License

MIT

Keywords

vue

FAQs

Package last updated on 22 Apr 2026

Related posts