125k

Dialog

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

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

インストール

pnpm dlx shadcn@latest add dialog

使い方

import { Button } from "@/components/ui/button"
import {
  Dialog,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"
<DialogTrigger>
  <Button>Open</Button>
  <Dialog>
    <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>
  </Dialog>
</DialogTrigger>

構成

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

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

カスタム閉じるボタン

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

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

閉じるボタンなし

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

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

スティッキー フッター

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

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

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

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

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

RTL

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

"use client"

import {

API リファレンス

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