Component

Dialog

安装 Installation

npx timkit add dialog --yes --framework react

用法 Usage

import { Dialog } from "@/components/ui/dialog"

className 与 variant、size 可以一起用。字段以 timkit agent inspect dialog --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

21 / 21

Dialog · Are you sure? · 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

dialog

Logic

zag / dialog

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
zagState and interaction provider used by this component.
logic.machine
string
dialogUnderlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/core, @zag-js/reactRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
use-machineDependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
disabled
boolean
falseWhen true, opening the dialog is ignored.
open
boolean
-The controlled open state.
defaultOpen
boolean
-The default open state.
modal
boolean
trueWhether the dialog is modal.

Events

PropTypeDefaultDescription
onOpenChange
event
-Event handler called when the open state changes.

TypeScript

来自 TypeScript 导出。

PropTypeDefaultDescription
id
string
-A unique identifier for the component.

Slots

PropTypeDefaultDescription
default
slot
-The dialog content

Parts

PropTypeDefaultDescription
root*
root
-The dialog container
trigger
part
-The toggle button
portal
part
-The portal container
overlay
part
-The dimmed background
content
part
-The dialog content
header
part
-The dialog header
footer
part
-The dialog footer
title
part
-The dialog title
description
part
-The dialog description
close
part
-The close button
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • Escape closes the dialog.
  • The close control is a button named Close and is in the tab order.
  • The dialog can take focus without entering the tab order.
  • In static HTML, that content uses tabindex -1.
  • On React and Vue, focus returns to the trigger.
  • A title names the dialog.
  • The title is a level 2 heading.
  • On React, in Vue, and in static HTML, the description is tied to the dialog.
  • An open dialog is visible as Opened.
  • A closed dialog has no open status.
  • An omitted name is Dialog.
  • In static HTML, the close control and Save are type button.
  • On the mini program, the close mark is hidden from the name.

行为契约

Contract

props、默认值和运行时状态。

  • A dialog is modal unless modal is false.
  • A non-modal dialog has no overlay, does not claim aria-modal, and a backdrop press does not close it.
  • A passed aria-label names it when no title is passed.
  • The close button is in the tab order.