125k

Dialog

プライマリ ウィンドウまたは別のダイアログ ウィンドウに重ねて表示されるウィンドウで、その下のコンテンツは不活性になります。

import { Button } from "@/components/ui/radix/button"
import {
  Dialog,

インストール

pnpm dlx shadcn@latest add dialog

使い方

import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"
<Dialog>
  <DialogTrigger>Open</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Are you absolutely sure?</DialogTitle>
      <DialogDescription>
        This action cannot be undone. This will permanently delete your account
        and remove your data from our servers.
      </DialogDescription>
    </DialogHeader>
  </DialogContent>
</Dialog>

構成

次の構成を使用して Dialog を構築します。

Dialog
├── DialogTrigger
└── DialogContent
    ├── DialogHeader
    │   ├── DialogTitle
    │   └── DialogDescription
    └── DialogFooter

カスタム閉じるボタン

デフォルトの閉じるコントロールを独自のボタンに置き換えます。

import { Button } from "@/components/ui/radix/button"
import {
  Dialog,

閉じるボタンなし

showCloseButton={false} を使用すると、閉じるボタンを非表示にできます。

import { Button } from "@/components/ui/radix/button"
import {
  Dialog,

スティッキー フッター

コンテンツがスクロールしている間、アクションを表示したままにします。

import { Button } from "@/components/ui/radix/button"
import {
  Dialog,

スクロール可能なコンテンツ

長いコンテンツはヘッダーを表示したままスクロールできます。

import { Button } from "@/components/ui/radix/button"
import {
  Dialog,

RTL

shadcn/ui で RTL サポートを有効にするには、RTL 構成ガイドを参照してください。

"use client"

import {

API リファレンス

詳細については、Radix UI のドキュメントを参照してください。