syncfusion-angular-popups

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Implementing Syncfusion Angular Popups

实现Syncfusion Angular弹窗组件

Dialog

Dialog

The Dialog component is a window that displays information to the user and is used to get user input. It supports both modal dialogs (blocking parent interaction) and modeless dialogs (allowing parent interaction).
Dialog组件是向用户展示信息并获取用户输入的窗口。它支持模态对话框(阻止父组件交互)和非模态对话框(允许父组件交互)两种模式。

Component Overview

组件概述

Key Features

核心特性

  • Modal & Modeless modes - Block or allow parent interaction
  • Templates - Customizable headers, content, and footers
  • Positioning - 9 built-in positions or custom placement
  • Animations - Smooth open/close effects (Fade, Zoom, Slide)
  • Draggable & Resizable - Allow users to move and resize dialogs
  • Forms Integration - Reactive and template-driven forms
  • Accessibility - Full WCAG 2.2 Level AA support with ARIA
  • Keyboard Navigation - Tab, Escape, Enter, and arrow keys
  • Responsive - Full-screen mode on mobile devices
  • 模态与非模态模式 - 阻止或允许父组件交互
  • 模板定制 - 可自定义头部、内容和底部
  • 定位功能 - 9种内置位置或自定义布局
  • 动画效果 - 流畅的打开/关闭动画(淡入、缩放、滑动)
  • 可拖拽与调整大小 - 允许用户移动和调整对话框尺寸
  • 表单集成 - 支持响应式表单和模板驱动表单
  • 无障碍支持 - 全面符合WCAG 2.2 Level AA标准,支持ARIA属性
  • 键盘导航 - 支持Tab、Escape、Enter和方向键操作
  • 响应式设计 - 在移动设备上自动切换为全屏模式

Documentation and Navigation Guide

文档与导航指南

When you need to implement Dialog features, follow these references:
当你需要实现Dialog功能时,请参考以下文档:

Getting Started

快速入门

📄 Read: references/dialog-getting-started.md
  • Installation and setup in Angular 21+
  • Basic dialog implementation
  • CSS imports and themes
  • Opening and closing dialogs
  • Built-in button support
📄 阅读: references/dialog-getting-started.md
  • Angular 21+中的安装与配置
  • 基础Dialog实现
  • CSS导入与主题设置
  • 对话框的打开与关闭
  • 内置按钮支持

Dialog Modes & Types

对话框模式与类型

📄 Read: references/dialog-modal-vs-modeless.md
  • Modal dialog behavior (blocks parent interaction)
  • Modeless dialog behavior (allows parent interaction)
  • Use cases and when to use each mode
  • Toggling between modes
  • Overlay customization and styling
📄 阅读: references/dialog-modal-vs-modeless.md
  • 模态对话框行为(阻止父组件交互)
  • 非模态对话框行为(允许父组件交互)
  • 使用场景及模式选择
  • 模式切换方法
  • 遮罩层定制与样式设置

Content & Templates

内容与模板

📄 Read: references/dialog-templates-and-content.md
  • Header templates and customization
  • Content as strings, HTML, or ng-template
  • Footer templates with buttons
  • Using ng-content for dynamic content
  • Button binding and click events
  • Dynamic button arrays
📄 阅读: references/dialog-templates-and-content.md
  • 头部模板定制
  • 内容支持字符串、HTML或ng-template
  • 带按钮的底部模板
  • 使用ng-content实现动态内容
  • 按钮绑定与点击事件处理
  • 动态按钮数组配置

Positioning & Sizing

定位与尺寸设置

📄 Read: references/dialog-positioning-and-sizing.md
  • Built-in positions (9 locations: Top, Center, Bottom, etc.)
  • Custom positioning with X, Y coordinates
  • Width and height configuration
  • Min/max height constraints
  • Responsive sizing on different screen sizes
  • Full-screen mode on mobile devices
📄 阅读: references/dialog-positioning-and-sizing.md
  • 内置位置(9种:顶部、居中、底部等)
  • 通过X、Y坐标自定义定位
  • 宽度与高度配置
  • 最小/最大高度限制
  • 不同屏幕尺寸下的响应式尺寸
  • 移动设备上的全屏模式

Styling & Customization

样式与定制

📄 Read: references/dialog-styling-and-customization.md
  • CSS class customization (header, content, footer, overlay)
  • Theme integration (Material, Bootstrap, Tailwind, Fluent)
  • Dark mode support
  • Animation effects (Fade, Zoom, SlideLeft, SlideRight, etc.)
  • Icon customization (close button, resize handles)
  • RTL (Right-to-Left) language support
📄 阅读: references/dialog-styling-and-customization.md
  • CSS类定制(头部、内容、底部、遮罩层)
  • 主题集成(Material、Bootstrap、Tailwind、Fluent)
  • 深色模式支持
  • 动画效果(淡入、缩放、左滑、右滑等)
  • 图标定制(关闭按钮、调整大小手柄)
  • RTL(从右到左)语言支持

Accessibility & Forms

无障碍与表单

📄 Read: references/dialog-accessibility-and-forms.md
  • WCAG 2.2 Level AA compliance standards
  • ARIA attributes (aria-labelledby, aria-describedby, aria-modal, aria-grabbed)
  • Keyboard navigation patterns (Tab, Shift+Tab, Escape, Enter)
  • Screen reader support and best practices
  • Form validation with FormValidator
  • Reactive forms patterns
  • Template-driven forms patterns
  • Custom validation rules and error handling
📄 阅读: references/dialog-accessibility-and-forms.md
  • WCAG 2.2 Level AA合规标准
  • ARIA属性(aria-labelledby、aria-describedby、aria-modal、aria-grabbed)
  • 键盘导航模式(Tab、Shift+Tab、Escape、Enter)
  • 屏幕阅读器支持与最佳实践
  • 结合FormValidator的表单验证
  • 响应式表单模式
  • 模板驱动表单模式
  • 自定义验证规则与错误处理

Interaction & Events

交互与事件

📄 Read: references/dialog-interaction-and-events.md
  • Dialog open/close events
  • Draggable dialogs (allow users to move dialogs)
  • Resizable dialogs (allow users to resize)
  • Button click events and handling
  • Content interaction patterns
  • Preventing dialog closure
  • Focus management
  • Dialog lifecycle events
📄 阅读: references/dialog-interaction-and-events.md
  • 对话框打开/关闭事件
  • 可拖拽对话框(允许用户移动)
  • 可调整大小的对话框(允许用户调整尺寸)
  • 按钮点击事件与处理
  • 内容交互模式
  • 阻止对话框关闭
  • 焦点管理
  • 对话框生命周期事件

Advanced Patterns

高级模式

📄 Read: references/dialog-advanced-patterns.md
  • Nested dialogs (dialog within dialog)
  • Ajax-loaded content dynamically
  • Utility functions for programmatic creation
  • Complex layouts (Rich Text Editor, multi-step forms)
  • Scroll handling and auto-centering
  • Custom event emitters
  • Routing integration patterns
📄 阅读: references/dialog-advanced-patterns.md
  • 嵌套对话框(对话框内嵌套对话框)
  • 动态加载Ajax内容
  • 程序化创建的工具函数
  • 复杂布局(富文本编辑器、多步骤表单)
  • 滚动处理与自动居中
  • 自定义事件发射器
  • 路由集成模式

API Reference (Complete)

完整API参考

📄 Read: references/dialog-api-reference.md
  • Complete Dialog API documentation
  • All valid properties with types and examples
  • All methods (show, hide, refresh, destroy)
  • All events (beforeOpen, beforeClose, drag, resize, etc.)
  • Interfaces and models (AnimationSettingsModel, ButtonPropsModel, etc.)
  • Valid enumerations (DialogEffect, ResizeDirections)
  • Official Syncfusion documentation links
📄 阅读: references/dialog-api-reference.md
  • 完整的Dialog API文档
  • 所有有效属性的类型与示例
  • 所有方法(show、hide、refresh、destroy)
  • 所有事件(beforeOpen、beforeClose、drag、resize等)
  • 接口与模型(AnimationSettingsModel、ButtonPropsModel等)
  • 有效枚举(DialogEffect、ResizeDirections)
  • Syncfusion官方文档链接

Quick Start Example

快速入门示例

Here's a minimal example to open a basic modal dialog:
typescript
import { Component, ViewChild } from '@angular/core';
import { DialogModule, DialogComponent } from '@syncfusion/ej2-angular-popups';

@Component({
  selector: 'app-root',
  imports: [DialogModule],
  template: `
    <div id="dialog-container" style="height: 500px;">
      <button class="e-control e-btn" (click)="onOpenDialog()">
        Open Dialog
      </button>
      
      <ejs-dialog 
        #ejDialog
        target="#dialog-container"
        [showCloseIcon]="true"
        width="400px"
        content="This is a Dialog content"
      >
        <ng-template #header>
          <div class="e-dlg-header-content">
            <span>Dialog Title</span>
          </div>
        </ng-template>
      </ejs-dialog>
    </div>
  `
})
export class AppComponent {
  @ViewChild('ejDialog') ejDialog!: DialogComponent;

  onOpenDialog(): void {
    this.ejDialog.show();
  }
}
CSS:
css
#dialog-container {
  height: 500px;
}
以下是打开基础模态对话框的最简示例:
typescript
import { Component, ViewChild } from '@angular/core';
import { DialogModule, DialogComponent } from '@syncfusion/ej2-angular-popups';

@Component({
  selector: 'app-root',
  imports: [DialogModule],
  template: `
    <div id="dialog-container" style="height: 500px;">
      <button class="e-control e-btn" (click)="onOpenDialog()">
        Open Dialog
      </button>
      
      <ejs-dialog 
        #ejDialog
        target="#dialog-container"
        [showCloseIcon]="true"
        width="400px"
        content="This is a Dialog content"
      >
        <ng-template #header>
          <div class="e-dlg-header-content">
            <span>Dialog Title</span>
          </div>
        </ng-template>
      </ejs-dialog>
    </div>
  `
})
export class AppComponent {
  @ViewChild('ejDialog') ejDialog!: DialogComponent;

  onOpenDialog(): void {
    this.ejDialog.show();
  }
}
CSS:
css
#dialog-container {
  height: 500px;
}

Common Patterns

常见模式

Pattern 1: Modal Confirmation Dialog

模式1:模态确认对话框

typescript
// Create a modal dialog for confirmation
<ejs-dialog 
  [isModal]="true"
  [showCloseIcon]="true"
  width="350px"
  content="Are you sure you want to delete this item?"
>
  <ng-template #footer>
    <button class="e-control e-btn e-primary" (click)="onConfirm()">
      Yes, Delete
    </button>
    <button class="e-control e-btn" (click)="onCancel()">
      Cancel
    </button>
  </ng-template>
</ejs-dialog>
typescript
// 创建用于确认的模态对话框
<ejs-dialog 
  [isModal]="true"
  [showCloseIcon]="true"
  width="350px"
  content="Are you sure you want to delete this item?"
>
  <ng-template #footer>
    <button class="e-control e-btn e-primary" (click)="onConfirm()">
      Yes, Delete
    </button>
    <button class="e-control e-btn" (click)="onCancel()">
      Cancel
    </button>
  </ng-template>
</ejs-dialog>

Pattern 2: Dialog with Form (Reactive Forms)

模式2:包含表单的对话框(响应式表单)

typescript
// Dialog containing a reactive form
<ejs-dialog [showCloseIcon]="true" width="450px">
  <form [formGroup]="form">
    <div class="e-dlg-content">
      <input formControlName="name" placeholder="Enter name" />
      <input formControlName="email" placeholder="Enter email" />
    </div>
  </form>
  
  <ng-template #footer>
    <button class="e-control e-btn e-primary" (click)="onSubmit()">
      Submit
    </button>
  </ng-template>
</ejs-dialog>
typescript
// 包含响应式表单的对话框
<ejs-dialog [showCloseIcon]="true" width="450px">
  <form [formGroup]="form">
    <div class="e-dlg-content">
      <input formControlName="name" placeholder="Enter name" />
      <input formControlName="email" placeholder="Enter email" />
    </div>
  </form>
  
  <ng-template #footer>
    <button class="e-control e-btn e-primary" (click)="onSubmit()">
      Submit
    </button>
  </ng-template>
</ejs-dialog>

Pattern 3: Positioned Dialog

模式3:自定义定位的对话框

typescript
// Dialog positioned at a specific location
<ejs-dialog 
  [position]="{ X: 100, Y: 50 }"
  width="400px"
  content="Positioned Dialog"
>
</ejs-dialog>
typescript
// 定位在特定位置的对话框
<ejs-dialog 
  [position]="{ X: 100, Y: 50 }"
  width="400px"
  content="Positioned Dialog"
>
</ejs-dialog>

Key Props Quick Reference

核心属性速查

PropertyTypePurposeExample
isModal
booleanBlock parent interaction
[isModal]="true"
showCloseIcon
booleanShow close button in header
[showCloseIcon]="true"
width
string | numberSet dialog width
width="400px"
height
string | numberSet dialog height
height="300px"
minHeight
string | numberMinimum height constraint
[minHeight]="200"
position
PositionDataModelSet position (X, Y) or preset
[position]="{ X: 'center', Y: 'center' }"
target
HTMLElement | stringSet container element
target="#container"
content
string | HTMLElementSet content text or HTML
content="Hello"
header
string | HTMLElementSet header text or element
header="Title"
buttons
ButtonPropsModel[]Add footer buttons
[buttons]="buttonArray"
closeOnEscape
booleanClose on Escape key
[closeOnEscape]="true"
allowDragging
booleanEnable header dragging
[allowDragging]="true"
enableResize
booleanEnable resizing
[enableResize]="true"
resizeHandles
ResizeDirections[]Specify resize directions
[resizeHandles]="['All']"
cssClass
stringCustom CSS class(es)
cssClass="custom-dialog"
animationSettings
AnimationSettingsModelConfigure animations
[animationSettings]="{ effect: 'FadeZoom' }"
enablePersistence
booleanSave state between reloads
[enablePersistence]="true"
zIndex
numberZ-order for layering
[zIndex]="1000"
属性类型用途示例
isModal
boolean阻止父组件交互
[isModal]="true"
showCloseIcon
boolean在头部显示关闭按钮
[showCloseIcon]="true"
width
string | number设置对话框宽度
width="400px"
height
string | number设置对话框高度
height="300px"
minHeight
string | number最小高度限制
[minHeight]="200"
position
PositionDataModel设置位置(X、Y)或预设值
[position]="{ X: 'center', Y: 'center' }"
target
HTMLElement | string设置容器元素
target="#container"
content
string | HTMLElement设置内容文本或HTML
content="Hello"
header
string | HTMLElement设置头部文本或元素
header="Title"
buttons
ButtonPropsModel[]添加底部按钮
[buttons]="buttonArray"
closeOnEscape
boolean按Escape键关闭
[closeOnEscape]="true"
allowDragging
boolean启用头部拖拽
[allowDragging]="true"
enableResize
boolean启用尺寸调整
[enableResize]="true"
resizeHandles
ResizeDirections[]指定调整方向
[resizeHandles]="['All']"
cssClass
string自定义CSS类
cssClass="custom-dialog"
animationSettings
AnimationSettingsModel配置动画效果
[animationSettings]="{ effect: 'FadeZoom' }"
enablePersistence
boolean在页面重载时保存状态
[enablePersistence]="true"
zIndex
number层级堆叠顺序
[zIndex]="1000"

Common Use Cases

常见使用场景

  1. Confirmation before delete - Modal dialog asking user to confirm deletion
  2. Form submission - Dialog with form for user to submit data
  3. Alerts and notifications - Display important information to users
  4. Multi-step processes - Use nested dialogs for workflows
  5. Settings panels - Modeless dialog for settings that don't block interaction
  6. Help and guidance - Display help content in a draggable dialog
  7. Loading states - Show progress in a dialog while processing
  8. Error handling - Display error messages in a modal

  1. 删除前确认 - 模态对话框询问用户是否确认删除
  2. 表单提交 - 包含表单的对话框,用于用户提交数据
  3. 警告与通知 - 向用户展示重要信息
  4. 多步骤流程 - 使用嵌套对话框实现工作流
  5. 设置面板 - 非模态对话框,不阻止用户交互
  6. 帮助与指引 - 在可拖拽对话框中展示帮助内容
  7. 加载状态 - 在处理过程中展示进度对话框
  8. 错误处理 - 在模态对话框中展示错误信息

Related Skills

相关技能

  • Dialog Animation - Customize open/close animations
  • Form Validation - Validate user input in dialogs
  • Routing Integration - Use dialogs with Angular routing
  • 对话框动画 - 自定义打开/关闭动画
  • 表单验证 - 验证对话框中的用户输入
  • 路由集成 - 在Angular路由中使用对话框

Predefined Dialogs

预定义对话框

This skill covers building alert, confirm, and prompt dialogs using Syncfusion's
DialogUtility
— a zero-template, utility-first approach to displaying modal feedback and user-input dialogs in Angular applications.
本部分介绍如何使用Syncfusion的
DialogUtility
构建警告、确认和提示对话框——这是一种无需模板、实用优先的方法,用于在Angular应用中展示模态反馈和用户输入对话框。

Which Dialog Type?

如何选择对话框类型?

NeedDialog TypeAPI
Warn/inform user, single OKAlert
DialogUtility.alert(...)
Ask for confirmation (OK + Cancel)Confirm
DialogUtility.confirm(...)
Collect user input (HTML content + OK + Cancel)Prompt
DialogUtility.confirm(...)
with input in
content
Key insight: Angular's predefined dialogs have no separate "prompt" method — use
DialogUtility.confirm()
with custom HTML in the
content
property to build a prompt pattern.
需求对话框类型API
警告/通知用户,仅需确认按钮警告对话框
DialogUtility.alert(...)
请求用户确认(确认+取消按钮)确认对话框
DialogUtility.confirm(...)
收集用户输入(HTML内容+确认+取消按钮)提示对话框
content
中嵌入输入框的
DialogUtility.confirm(...)
核心提示: Angular的预定义对话框没有单独的"prompt"方法——使用
DialogUtility.confirm()
并在
content
属性中添加自定义HTML来实现提示对话框模式。

Quick Start

快速入门

bash
ng add @syncfusion/ej2-angular-popups
typescript
// src/app/app.ts
import { Component } from '@angular/core';
import { DialogModule } from '@syncfusion/ej2-angular-popups';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { DialogUtility } from '@syncfusion/ej2-popups';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [DialogModule, ButtonModule],
  template: `
    <button ejs-button cssClass="e-danger" (click)="showAlert()">Alert</button>
    <button ejs-button cssClass="e-success" (click)="showConfirm()" style="margin-left:8px">Confirm</button>
    <button ejs-button [isPrimary]="true" (click)="showPrompt()" style="margin-left:8px">Prompt</button>
  `
})
export class App {
  showAlert(): void {
    DialogUtility.alert({
      title: 'Warning',
      content: 'Disk space is running low.',
      width: '280px'
    });
  }

  showConfirm(): void {
    const dlg = DialogUtility.confirm({
      title: 'Delete Item',
      content: 'Are you sure you want to delete this item?',
      width: '300px',
      okButton: { text: 'Yes', click: () => { dlg.hide(); /* handle confirm */ } },
      cancelButton: { text: 'No', click: () => { dlg.hide(); } }
    });
  }

  showPrompt(): void {
    const dlg = DialogUtility.confirm({
      title: 'Enter Name',
      content: '<p>Your name:</p><input id="nameInput" class="e-input" type="text" placeholder="Type here..." />',
      width: '300px',
      okButton: {
        text: 'Submit',
        click: () => {
          const value = (document.getElementById('nameInput') as HTMLInputElement).value;
          dlg.hide();
          // use value
        }
      },
      cancelButton: { text: 'Cancel', click: () => dlg.hide() }
    });
  }
}
css
/* styles.css */
@import '../node_modules/@syncfusion/ej2-base/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-icons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-angular-popups/styles/material3.css';
bash
ng add @syncfusion/ej2-angular-popups
typescript
// src/app/app.ts
import { Component } from '@angular/core';
import { DialogModule } from '@syncfusion/ej2-angular-popups';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { DialogUtility } from '@syncfusion/ej2-popups';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [DialogModule, ButtonModule],
  template: `
    <button ejs-button cssClass="e-danger" (click)="showAlert()">Alert</button>
    <button ejs-button cssClass="e-success" (click)="showConfirm()" style="margin-left:8px">Confirm</button>
    <button ejs-button [isPrimary]="true" (click)="showPrompt()" style="margin-left:8px">Prompt</button>
  `
})
export class App {
  showAlert(): void {
    DialogUtility.alert({
      title: 'Warning',
      content: 'Disk space is running low.',
      width: '280px'
    });
  }

  showConfirm(): void {
    const dlg = DialogUtility.confirm({
      title: 'Delete Item',
      content: 'Are you sure you want to delete this item?',
      width: '300px',
      okButton: { text: 'Yes', click: () => { dlg.hide(); /* handle confirm */ } },
      cancelButton: { text: 'No', click: () => { dlg.hide(); } }
    });
  }

  showPrompt(): void {
    const dlg = DialogUtility.confirm({
      title: 'Enter Name',
      content: '<p>Your name:</p><input id="nameInput" class="e-input" type="text" placeholder="Type here..." />',
      width: '300px',
      okButton: {
        text: 'Submit',
        click: () => {
          const value = (document.getElementById('nameInput') as HTMLInputElement).value;
          dlg.hide();
          // use value
        }
      },
      cancelButton: { text: 'Cancel', click: () => dlg.hide() }
    });
  }
}
css
/* styles.css */
@import '../node_modules/@syncfusion/ej2-base/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-icons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-angular-popups/styles/material3.css';

Common Patterns

常见模式

Pattern 1 — Delete confirmation with icons:
typescript
DialogUtility.confirm({
  title: 'Delete Files',
  content: 'Permanently delete selected files?',
  width: '300px',
  okButton: { text: 'Yes', icon: 'e-icons e-check' },
  cancelButton: { text: 'No', icon: 'e-icons e-close' }
});
Pattern 2 — Alert with close button + ESC support:
typescript
DialogUtility.alert({
  title: 'Session Expired',
  content: 'Your session has expired. Please log in again.',
  width: '300px',
  showCloseIcon: true,
  closeOnEscape: true
});
Pattern 3 — Positioned modal confirm:
typescript
DialogUtility.confirm({
  title: 'Confirm Action',
  content: 'Submit the form?',
  isModal: true,
  position: { X: 'center', Y: 'center' },
  animationSettings: { effect: 'Zoom' },
  isDraggable: true,
  width: '280px'
});
模式1 — 带图标的删除确认对话框:
typescript
DialogUtility.confirm({
  title: 'Delete Files',
  content: 'Permanently delete selected files?',
  width: '300px',
  okButton: { text: 'Yes', icon: 'e-icons e-check' },
  cancelButton: { text: 'No', icon: 'e-icons e-close' }
});
模式2 — 带关闭按钮和ESC支持的警告对话框:
typescript
DialogUtility.alert({
  title: 'Session Expired',
  content: 'Your session has expired. Please log in again.',
  width: '300px',
  showCloseIcon: true,
  closeOnEscape: true
});
模式3 — 自定义定位的模态确认对话框:
typescript
DialogUtility.confirm({
  title: 'Confirm Action',
  content: 'Submit the form?',
  isModal: true,
  position: { X: 'center', Y: 'center' },
  animationSettings: { effect: 'Zoom' },
  isDraggable: true,
  width: '280px'
});

Key Properties at a Glance

核心属性速览

PropertyPurposeDefault
title
Dialog header text
content
Body text or HTML string
width
Dialog width (px or %)
'100%'
isModal
Overlay + modal behavior
false
isDraggable
Allow header drag to reposition
false
showCloseIcon
Show × close button
false
closeOnEscape
Close on ESC key
false
position
{ X, Y }
— predefined or offset
center/center
animationSettings
{ effect, duration, delay }
Fade, 400ms
okButton
OK button config
{ text, icon, click }
cancelButton
Cancel button config
{ text, icon, click }
cssClass
Custom CSS class on dialog root
''
zIndex
Stacking order
1000
open
Callback after dialog opens
close
Callback after dialog closes
属性用途默认值
title
对话框头部文本
content
主体文本或HTML字符串
width
对话框宽度(px或%)
'100%'
isModal
遮罩层+模态行为
false
isDraggable
允许通过头部拖拽调整位置
false
showCloseIcon
显示×关闭按钮
false
closeOnEscape
按ESC键关闭
false
position
{ X, Y }
— 预设值或偏移量
center/center
animationSettings
{ effect, duration, delay }
Fade, 400ms
okButton
确认按钮配置
{ text, icon, click }
cancelButton
取消按钮配置
{ text, icon, click }
cssClass
对话框根元素的自定义CSS类
''
zIndex
堆叠顺序
1000
open
对话框打开后的回调
close
对话框关闭后的回调

Documentation

文档

Getting Started

快速入门

📄 Read: references/getting-started.md
  • Installation and package setup
  • CSS imports and theme options
  • Basic alert, confirm, and prompt examples
  • All
    DialogUtility
    option properties
📄 阅读: references/getting-started.md
  • 安装与包配置
  • CSS导入与主题选项
  • 基础警告、确认和提示对话框示例
  • DialogUtility
    的所有配置属性

Customization

定制

📄 Read: references/customization.md
  • Button text and icon customization
  • Show/hide close icon and ESC behavior
  • Custom HTML content in dialogs
  • Programmatic dialog close with
    hide()
📄 阅读: references/customization.md
  • 按钮文本与图标定制
  • 显示/隐藏关闭按钮与ESC行为设置
  • 对话框中的自定义HTML内容
  • 使用
    hide()
    程序化关闭对话框

Position and Dimension

定位与尺寸

📄 Read: references/position-and-dimension.md
  • Position X/Y values and offset usage
  • Width and height properties
  • Max-width/max-height via
    cssClass
  • Min-width/min-height via
    cssClass
📄 阅读: references/position-and-dimension.md
  • X/Y位置值与偏移量用法
  • 宽度与高度属性
  • 通过
    cssClass
    设置最大宽度/高度
  • 通过
    cssClass
    设置最小宽度/高度

Animation and Draggable

动画与拖拽

📄 Read: references/animation-and-draggable.md
  • animationSettings
    effect options (Zoom, Fade, FadeZoom, etc.)
  • Duration and delay configuration
  • isDraggable
    for all dialog types
📄 阅读: references/animation-and-draggable.md
  • animationSettings
    支持的动画效果(缩放、淡入、淡入缩放等)
  • 时长与延迟配置
  • 所有对话框类型的
    isDraggable
    设置

Events and Patterns

事件与模式

📄 Read: references/events-and-patterns.md
  • open
    and
    close
    event callbacks
  • isModal
    ,
    zIndex
    ,
    cssClass
    advanced usage
  • Common real-world patterns (delete confirm, form prompt, info alert)
  • Managing multiple dialog instances
📄 阅读: references/events-and-patterns.md
  • open
    close
    事件回调
  • isModal
    zIndex
    cssClass
    的高级用法
  • 常见实际场景(删除确认、表单提示、信息警告)
  • 多对话框实例管理

API Reference

API参考

📄 Read: references/api.md
  • Complete
    DialogUtility.alert()
    and
    DialogUtility.confirm()
    options
  • okButton
    /
    cancelButton
    ButtonArgs properties
  • AnimationSettingsModel
    properties
  • PositionDataModel
    properties
  • DialogComponent
    properties, methods, and events
📄 阅读: references/api.md
  • DialogUtility.alert()
    DialogUtility.confirm()
    的完整配置选项
  • okButton
    /
    cancelButton
    的ButtonArgs属性
  • AnimationSettingsModel
    属性
  • PositionDataModel
    属性
  • DialogComponent
    的属性、方法与事件

Tooltip

Tooltip

The Syncfusion Angular Tooltip (
ejs-tooltip
) displays a pop-up with information or a message when you hover, click, focus, or touch a target element. It supports 12 positions, animations, HTML/template/AJAX content, sticky mode, mouse trailing, and full accessibility compliance.
Syncfusion Angular Tooltip(
ejs-tooltip
)会在用户悬停、点击、聚焦或触摸目标元素时,弹出包含信息或消息的窗口。它支持12种定位方式、动画效果、HTML/模板/AJAX内容、粘性模式、鼠标跟随,且完全符合无障碍标准。

Navigation Guide

导航指南

Getting Started

快速入门

📄 Read: references/getting-started.md
  • Installation and package setup (
    ng add @syncfusion/ej2-angular-popups
    )
  • CSS theme imports
  • Basic single-target tooltip
  • Multi-target tooltip with
    target
    property
  • Standalone (Angular 19+) and module-based setup
📄 阅读: references/getting-started.md
  • 安装与包配置(
    ng add @syncfusion/ej2-angular-popups
  • CSS主题导入
  • 基础单目标Tooltip
  • 使用
    target
    属性实现多目标Tooltip
  • 独立组件(Angular 19+)与基于模块的配置

Content

内容

📄 Read: references/content.md
  • Static text and HTML string content
  • Template content using
    ng-template
  • Dynamic content via AJAX/Fetch in
    beforeRender
    event
  • Loading HTML elements (iframes, videos) in tooltip
  • enableHtmlParse
    and
    enableHtmlSanitizer
    options
📄 阅读: references/content.md
  • 静态文本与HTML字符串内容
  • 使用
    ng-template
    实现模板内容
  • 通过
    beforeRender
    事件加载AJAX/Fetch动态内容
  • 在Tooltip中加载HTML元素(iframe、视频)
  • enableHtmlParse
    enableHtmlSanitizer
    选项

Position & Dimensions

定位与尺寸

📄 Read: references/position-and-dimension.md
  • All 12 position values (
    TopCenter
    ,
    BottomLeft
    , etc.)
  • Tip pointer show/hide and position
  • Mouse trailing
  • Offset values (
    offsetX
    ,
    offsetY
    )
  • Width, height, and scroll mode
  • Window collision handling
📄 阅读: references/position-and-dimension.md
  • 所有12种定位值(
    TopCenter
    BottomLeft
    等)
  • 提示箭头的显示/隐藏与定位
  • 鼠标跟随
  • 偏移量设置(
    offsetX
    offsetY
  • 宽度、高度与滚动模式
  • 窗口碰撞处理

Open Modes

触发模式

📄 Read: references/open-mode.md
  • opensOn
    : Auto, Hover, Click, Focus, Custom
  • Combining multiple open modes
  • Custom mode with programmatic
    open()
    /
    close()
  • Sticky mode (
    isSticky
    )
  • Open/close delay
📄 阅读: references/open-mode.md
  • opensOn
    :自动、悬停、点击、聚焦、自定义
  • 组合多种触发模式
  • 自定义模式下的程序化
    open()
    /
    close()
  • 粘性模式(
    isSticky
  • 打开/关闭延迟

Animation

动画

📄 Read: references/animation.md
  • animation
    property with open/close settings
  • All supported animation effects
  • Applying animations via
    open()
    /
    close()
    methods
  • Custom transition effects
📄 阅读: references/animation.md
  • 包含打开/关闭设置的
    animation
    属性
  • 所有支持的动画效果
  • 通过
    open()
    /
    close()
    方法应用动画
  • 自定义过渡效果

Customization & Style

定制与样式

📄 Read: references/customization-and-style.md
  • cssClass
    for custom styles
  • CSS class reference for tooltip structure
  • Tip pointer customization
  • Fancy tips (curved, bubble)
  • SVG and canvas tooltips
  • Tooltips on disabled elements
  • Container, RTL, htmlAttributes
📄 阅读: references/customization-and-style.md
  • 用于自定义样式的
    cssClass
  • Tooltip结构的CSS类参考
  • 提示箭头定制
  • 花式提示(弧形、气泡)
  • SVG与Canvas Tooltip
  • 禁用元素上的Tooltip
  • 容器、RTL、htmlAttributes

Accessibility

无障碍支持

📄 Read: references/accessibility.md
  • WCAG 2.2, Section 508 compliance
  • WAI-ARIA attributes
  • Keyboard navigation
  • Screen reader support
📄 阅读: references/accessibility.md
  • WCAG 2.2、Section 508合规
  • WAI-ARIA属性
  • 键盘导航
  • 屏幕阅读器支持

API Reference

API参考

📄 Read: references/api.md
  • All properties, methods, and events
  • Type definitions and defaults
  • TooltipEventArgs
    ,
    AnimationModel
    ,
    TooltipAnimationSettings
  • Position
    ,
    TipPointerPosition
    , and
    Effect
    enumerations
📄 阅读: references/api.md
  • 所有属性、方法与事件
  • 类型定义与默认值
  • TooltipEventArgs
    AnimationModel
    TooltipAnimationSettings
  • Position
    TipPointerPosition
    Effect
    枚举

Quick Start

快速入门

bash
ng add @syncfusion/ej2-angular-popups
typescript
// src/app/app.ts (Angular 19+ standalone)
import { Component, ViewEncapsulation } from '@angular/core';
import { TooltipModule } from '@syncfusion/ej2-angular-popups';

@Component({
  standalone: true,
  imports: [TooltipModule],
  selector: 'app-root',
  encapsulation: ViewEncapsulation.None,
  template: `
    <ejs-tooltip content="Hello, I am a Tooltip!" position="BottomCenter">
      <button>Hover me</button>
    </ejs-tooltip>
  `
})
export class App {}
css
/* styles.css */
@import "@syncfusion/ej2-base/styles/material3.css";
@import "@syncfusion/ej2-angular-buttons/styles/material3.css";
@import "@syncfusion/ej2-angular-popups/styles/material3.css";
bash
ng add @syncfusion/ej2-angular-popups
typescript
// src/app/app.ts (Angular 19+独立组件)
import { Component, ViewEncapsulation } from '@angular/core';
import { TooltipModule } from '@syncfusion/ej2-angular-popups';

@Component({
  standalone: true,
  imports: [TooltipModule],
  selector: 'app-root',
  encapsulation: ViewEncapsulation.None,
  template: `
    <ejs-tooltip content="Hello, I am a Tooltip!" position="BottomCenter">
      <button>Hover me</button>
    </ejs-tooltip>
  `
})
export class App {}
css
/* styles.css */
@import "@syncfusion/ej2-base/styles/material3.css";
@import "@syncfusion/ej2-angular-buttons/styles/material3.css";
@import "@syncfusion/ej2-angular-popups/styles/material3.css";

Common Patterns

常见模式

Multi-target tooltip (single instance)

多目标Tooltip(单实例)

html
<!-- Wraps a container; target selector picks which children get tooltips -->
<ejs-tooltip target=".has-tip">
  <div id="container">
    <button class="has-tip" title="Save your work">Save</button>
    <button class="has-tip" title="Delete selected item">Delete</button>
    <button>No tooltip here</button>
  </div>
</ejs-tooltip>
html
<!-- 包裹容器;target选择器指定哪些子元素显示Tooltip -->
<ejs-tooltip target=".has-tip">
  <div id="container">
    <button class="has-tip" title="Save your work">Save</button>
    <button class="has-tip" title="Delete selected item">Delete</button>
    <button>No tooltip here</button>
  </div>
</ejs-tooltip>

Tooltip that opens on click

点击触发的Tooltip

html
<ejs-tooltip content="Clicked!" opensOn="Click" position="RightCenter">
  <button>Click me</button>
</ejs-tooltip>
html
<ejs-tooltip content="Clicked!" opensOn="Click" position="RightCenter">
  <button>Click me</button>
</ejs-tooltip>

Sticky tooltip with close button

带关闭按钮的粘性Tooltip

html
<ejs-tooltip content="I stay until you close me." [isSticky]="true">
  <span>Hover and pin me</span>
</ejs-tooltip>
html
<ejs-tooltip content="I stay until you close me." [isSticky]="true">
  <span>Hover and pin me</span>
</ejs-tooltip>

HTML content tooltip

HTML内容Tooltip

typescript
public htmlContent: string = '<b>Bold</b> and <i>italic</i> text with a <a href="#">link</a>.';
html
<ejs-tooltip [content]="htmlContent">
  <button>Rich content</button>
</ejs-tooltip>
typescript
public htmlContent: string = '<b>Bold</b> and <i>italic</i> text with a <a href="#">link</a>.';
html
<ejs-tooltip [content]="htmlContent">
  <button>Rich content</button>
</ejs-tooltip>

Programmatic open/close (custom mode)

程序化打开/关闭(自定义模式)

typescript
@ViewChild('tooltip') tooltip!: TooltipComponent;

openTip(): void {
  this.tooltip.open(this.tooltip.element);
}
closeTip(): void {
  this.tooltip.close();
}
html
<ejs-tooltip #tooltip content="Custom trigger" opensOn="Custom">
  <span>Target</span>
</ejs-tooltip>
<button (click)="openTip()">Show</button>
<button (click)="closeTip()">Hide</button>
typescript
@ViewChild('tooltip') tooltip!: TooltipComponent;

openTip(): void {
  this.tooltip.open(this.tooltip.element);
}
closeTip(): void {
  this.tooltip.close();
}
html
<ejs-tooltip #tooltip content="Custom trigger" opensOn="Custom">
  <span>Target</span>
</ejs-tooltip>
<button (click)="openTip()">Show</button>
<button (click)="closeTip()">Hide</button>

Key Properties at a Glance

核心属性速览

PropertyTypeDefaultPurpose
content
string | HTMLElement
Tooltip content
position
Position
'TopCenter'
Where tooltip appears
opensOn
string
'Auto'
Trigger: Auto/Hover/Click/Focus/Custom
isSticky
boolean
false
Keep open until manually closed
mouseTrail
boolean
false
Follow mouse pointer
openDelay
number
0
Delay (ms) before opening
closeDelay
number
0
Delay (ms) before closing
animation
AnimationModel
FadeIn/FadeOut 150msOpen/close animation
target
string
Selector for multi-target
cssClass
string
null
Custom CSS class
showTipPointer
boolean
true
Show/hide arrow tip
width
/
height
string | number
'auto'
Dimensions
For full property, method, and event reference, read references/api.md.
属性类型默认值用途
content
string | HTMLElement
Tooltip内容
position
Position
'TopCenter'
Tooltip显示位置
opensOn
string
'Auto'
触发方式:自动/悬停/点击/聚焦/自定义
isSticky
boolean
false
保持打开状态直到手动关闭
mouseTrail
boolean
false
跟随鼠标指针移动
openDelay
number
0
打开延迟(毫秒)
closeDelay
number
0
关闭延迟(毫秒)
animation
AnimationModel
淡入/淡出 150ms打开/关闭动画
target
string
多目标选择器
cssClass
string
null
自定义CSS类
showTipPointer
boolean
true
显示/隐藏箭头提示
width
/
height
string | number
'auto'
尺寸设置
如需完整的属性、方法与事件参考,请阅读references/api.md