Skip to content
Tennantite
中文
Documentation

Dialog

Modal dialog built on Base UI Dialog: translucent backdrop and dark panel.

Install

CLI copy

$npx shadcn add @tennantite/dialog

npm install

$pnpm add @tennantite/ui

npm installs the compiled package; use the CLI copy above to adapt the source.

Usage

npm import

import { Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogPopup, DialogTitle, DialogTrigger } from "@tennantite/ui";

CLI copy import

import { Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogPopup, DialogTitle, DialogTrigger } from "@/components/tennantite/dialog";
"use client";

import { useState } from "react";

import { Button } from "../button/index";
import { Dialog, DialogClose, DialogDescription, DialogPopup, DialogTitle, DialogTrigger } from "./index";

/**
 * Dialog 预览用例:确认框
*/
export function DialogDemo() {
  const [open, setOpen] = useState(false);

  return (
    <Dialog onOpenChange={setOpen} open={open}>
      <DialogTrigger
        render={
          <Button>保存并退出到标题界面</Button>
        }
      />
      <DialogPopup>
        <DialogTitle>确认退出?</DialogTitle>
        <DialogDescription className="mt-4">
          未保存的进度将会丢失。
        </DialogDescription>
        <div className="mt-12 flex justify-end gap-8">
          <DialogClose render={<Button variant="ghost" />}>取消</DialogClose>
          <DialogClose render={<Button variant="success" />}>退出</DialogClose>
        </div>
      </DialogPopup>
    </Dialog>
  );
}

API Reference

PropTypeDefaultDescription
variant"overlay" | "panel""panel"Popup appearance: panel centered window panel / overlay fullscreen without backdrop (pause, death screen). DialogPopup only.

Source

packages/ui/src/primitives/dialog/index.tsx

The npm package keeps the source tree, so you can copy and adapt it directly.