ModalDialogAPI
React ModalDialog 元件的 API 參考文件。了解此匯出模組的 props、CSS 和其他 API。
示範
Import
import ModalDialog from '@mui/joy/ModalDialog';
// or
import { ModalDialog } from '@mui/joy';
閱讀關於最小化 bundle 大小的指南,以了解差異。
原生元件的 Props 也可使用。
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
children | node | - | 元件的內容。 |
color | 'danger' | 'neutral' | 'primary' | 'success' | 'warning' | string | 'neutral' | 元件的顏色。它支援適用於此元件的佈景主題顏色。 若要了解如何新增自己的顏色,請查看佈景主題元件—延伸顏色。 |
component | elementType | - | 用於根節點的元件。可以是使用 HTML 元素的字串或元件。 |
invertedColors | bool | false | 若為 |
layout | 'center' | 'fullscreen' | string | 'center' | 對話框的版面配置 |
maxWidth | number | string | - | 元件的最大寬度。 |
minWidth | number | string | - | 元件的最小寬度。 |
orientation | 'horizontal' | 'vertical' | 'vertical' | 元件方向。 |
size | 'sm' | 'md' | 'lg' | string | 'md' | 元件的大小。 若要了解如何將自訂大小新增至元件,請查看佈景主題元件—延伸大小。 |
slotProps | { root?: func | object } | {} | 用於每個內部 slot 的 props。 |
slots | { root?: elementType } | {} | 用於每個內部 slot 的元件。 請參閱下方的Slots API 以了解更多詳細資訊。 |
sx | Array<func | object | bool> | func | object | - | 系統 prop,允許定義系統覆寫以及其他 CSS 樣式。 請參閱 `sx` 頁面 以了解更多詳細資訊。 |
variant | 'outlined' | 'plain' | 'soft' | 'solid' | string | 'outlined' | 要使用的全域 variant。 若要了解如何新增自己的 variant,請查看佈景主題元件—延伸 variants。 |
ref
轉發到根元素。佈景主題預設 props
您可以使用 JoyModalDialog
透過佈景主題變更此元件的預設 props。
若要了解如何自訂 slot,請查看覆寫元件結構指南。
Slot 名稱 | Class name | 預設元件 | 描述 |
---|---|---|---|
root | .MuiModalDialog-root | 'div' | 呈現 root 的元件。 |
這些 class name 對於使用 CSS 設定樣式很有用。當觸發特定狀態時,它們會套用至元件的 slot。
Class name | Rule name | 描述 |
---|---|---|
.MuiModalDialog-colorContext | colorContext | 當觸發顏色反轉時,套用至根元素的 Class name。 |
.MuiModalDialog-colorDanger | colorDanger | 若 color="danger" ,則套用至根元素的 Class name。 |
.MuiModalDialog-colorNeutral | colorNeutral | 若 color="neutral" ,則套用至根元素的 Class name。 |
.MuiModalDialog-colorPrimary | colorPrimary | 若 color="primary" ,則套用至根元素的 Class name。 |
.MuiModalDialog-colorSuccess | colorSuccess | 若 color="success" ,則套用至根元素的 Class name。 |
.MuiModalDialog-colorWarning | colorWarning | 若 color="warning" ,則套用至根元素的 Class name。 |
.MuiModalDialog-layoutCenter | layoutCenter | 若 layout="center" ,則套用至根元素的 Class name。 |
.MuiModalDialog-layoutFullscreen | layoutFullscreen | 若 layout="fullscreen" ,則套用至根元素的 Class name。 |
.MuiModalDialog-sizeLg | sizeLg | 若 size="lg" ,則套用至根元素的 Class name。 |
.MuiModalDialog-sizeMd | sizeMd | 若 size="md" ,則套用至根元素的 Class name。 |
.MuiModalDialog-sizeSm | sizeSm | 若 size="sm" ,則套用至根元素的 Class name。 |
.MuiModalDialog-variantOutlined | variantOutlined | 若 variant="outlined" ,則套用至根元素的 Class name。 |
.MuiModalDialog-variantPlain | variantPlain | 若 variant="plain" ,則套用至根元素的 Class name。 |
.MuiModalDialog-variantSoft | variantSoft | 若 variant="soft" ,則套用至根元素的 Class name。 |
.MuiModalDialog-variantSolid | variantSolid | 若 variant="solid" ,則套用至根元素的 Class name。 |
您可以使用下列其中一種自訂選項來覆寫元件的樣式
- 使用全域 class name。
- 在自訂佈景主題中使用 rule name 作為元件
styleOverrides
屬性的一部分。
原始碼
如果您在此頁面中找不到資訊,請考慮查看元件的實作以取得更多詳細資訊。