GridLegacyAPI
React GridLegacy 元件的 API 參考文件。了解此匯出模組的 props、CSS 和其他 API。
範例
導入
import GridLegacy from '@mui/material/GridLegacy';
// or
import { GridLegacy } from '@mui/material';
請`閱讀這份關於最小化 bundle size 的指南`,以了解差異。
也提供原生元件的 Props。
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
children | node | - | 元件的內容。 |
classes | object | - | 覆寫或擴展套用至元件的樣式。 請參閱下方 `CSS 類別 API` 以取得更多詳細資訊。 |
columns | Array<number> | number | object | 12 | 欄數。 |
columnSpacing | Array<number | string> | number | object | string | - | 定義 `item` 類型元件之間的水平間距。它會覆寫 `spacing` prop 的值。 |
component | elementType | - | 用於根節點的元件。可以是字串 (用於 HTML 元素) 或元件。 |
container | bool | false | 如果為 `true`,元件將具有 flex *container* 行為。您應該使用 *container* 包裝 *items*。 |
direction | 'column-reverse' | 'column' | 'row-reverse' | 'row' | Array<'column-reverse' | 'column' | 'row-reverse' | 'row'> | object | 'row' | 定義 `flex-direction` 樣式屬性。它適用於所有螢幕尺寸。 |
item | bool | false | 如果為 `true`,元件將具有 flex *item* 行為。您應該使用 *container* 包裝 *items*。 |
lg | 'auto' | number | bool | false | 如果是數字,則設定 grid item 使用的欄數。它不能大於 container 的總欄數 (預設為 12)。如果為 'auto',grid item 的寬度會符合其內容。如果為 false,則會忽略該 prop。如果為 true,grid item 的寬度會擴展以使用 grid container 中可用的空間。該值適用於 `lg` breakpoint 和更寬的螢幕 (如果未被覆寫)。 |
md | 'auto' | number | bool | false | 如果是數字,則設定 grid item 使用的欄數。它不能大於 container 的總欄數 (預設為 12)。如果為 'auto',grid item 的寬度會符合其內容。如果為 false,則會忽略該 prop。如果為 true,grid item 的寬度會擴展以使用 grid container 中可用的空間。該值適用於 `md` breakpoint 和更寬的螢幕 (如果未被覆寫)。 |
rowSpacing | Array<number | string> | number | object | string | - | 定義 `item` 類型元件之間的垂直間距。它會覆寫 `spacing` prop 的值。 |
sm | 'auto' | number | bool | false | 如果是數字,則設定 grid item 使用的欄數。它不能大於 container 的總欄數 (預設為 12)。如果為 'auto',grid item 的寬度會符合其內容。如果為 false,則會忽略該 prop。如果為 true,grid item 的寬度會擴展以使用 grid container 中可用的空間。該值適用於 `sm` breakpoint 和更寬的螢幕 (如果未被覆寫)。 |
spacing | Array<number | string> | number | object | string | 0 | 定義 `item` 類型元件之間的間距。它只能在 `container` 類型元件上使用。 |
sx | Array<func | object | bool> | func | object | - | 允許定義系統覆寫以及額外 CSS 樣式的系統 prop。 請參閱 ``sx` 頁面` 以取得更多詳細資訊。 |
wrap | 'nowrap' | 'wrap-reverse' | 'wrap' | 'wrap' | 定義 `flex-wrap` 樣式屬性。它適用於所有螢幕尺寸。 |
xl | 'auto' | number | bool | false | 如果是數字,則設定 grid item 使用的欄數。它不能大於 container 的總欄數 (預設為 12)。如果為 'auto',grid item 的寬度會符合其內容。如果為 false,則會忽略該 prop。如果為 true,grid item 的寬度會擴展以使用 grid container 中可用的空間。該值適用於 `xl` breakpoint 和更寬的螢幕 (如果未被覆寫)。 |
xs | 'auto' | number | bool | false | 如果是數字,則設定 grid item 使用的欄數。它不能大於 container 的總欄數 (預設為 12)。如果為 'auto',grid item 的寬度會符合其內容。如果為 false,則會忽略該 prop。如果為 true,grid item 的寬度會擴展以使用 grid container 中可用的空間。該值適用於所有螢幕尺寸,優先順序最低。 |
zeroMinWidth | bool | false | 如果為 `true`,則在 item 上設定 `min-width: 0`。請參閱文件中的限制章節,以更了解使用案例。 |
主題預設 props
您可以使用 `MuiGridLegacy` `透過主題` 變更此元件的預設 props。
這些類別名稱對於使用 CSS 設定樣式很有用。當觸發特定狀態時,它們會套用至元件的 slots。
類別名稱 | 規則名稱 | 描述 |
---|---|---|
.MuiGridLegacy-container | container | 如果 container={true} ,套用至根元素的樣式。 |
.MuiGridLegacy-direction-xs-column | direction-xs-column | 如果 direction="column" ,套用至根元素的樣式。 |
.MuiGridLegacy-direction-xs-column-reverse | direction-xs-column-reverse | 如果 direction="column-reverse" ,套用至根元素的樣式。 |
.MuiGridLegacy-direction-xs-row-reverse | direction-xs-row-reverse | 如果 direction="row-reverse" ,套用至根元素的樣式。 |
.MuiGridLegacy-grid-xs-1 | grid-xs-1 | |
.MuiGridLegacy-grid-xs-10 | grid-xs-10 | |
.MuiGridLegacy-grid-xs-11 | grid-xs-11 | |
.MuiGridLegacy-grid-xs-12 | grid-xs-12 | |
.MuiGridLegacy-grid-xs-2 | grid-xs-2 | |
.MuiGridLegacy-grid-xs-3 | grid-xs-3 | |
.MuiGridLegacy-grid-xs-4 | grid-xs-4 | |
.MuiGridLegacy-grid-xs-5 | grid-xs-5 | |
.MuiGridLegacy-grid-xs-6 | grid-xs-6 | |
.MuiGridLegacy-grid-xs-7 | grid-xs-7 | |
.MuiGridLegacy-grid-xs-8 | grid-xs-8 | |
.MuiGridLegacy-grid-xs-9 | grid-xs-9 | |
.MuiGridLegacy-grid-xs-auto | grid-xs-auto | |
.MuiGridLegacy-grid-xs-true | grid-xs-true | |
.MuiGridLegacy-item | item | 如果 item={true} ,套用至根元素的樣式。 |
.MuiGridLegacy-root | root | 套用至根元素的樣式。 |
.MuiGridLegacy-spacing-xs-1 | spacing-xs-1 | |
.MuiGridLegacy-spacing-xs-10 | spacing-xs-10 | |
.MuiGridLegacy-spacing-xs-2 | spacing-xs-2 | |
.MuiGridLegacy-spacing-xs-3 | spacing-xs-3 | |
.MuiGridLegacy-spacing-xs-4 | spacing-xs-4 | |
.MuiGridLegacy-spacing-xs-5 | spacing-xs-5 | |
.MuiGridLegacy-spacing-xs-6 | spacing-xs-6 | |
.MuiGridLegacy-spacing-xs-7 | spacing-xs-7 | |
.MuiGridLegacy-spacing-xs-8 | spacing-xs-8 | |
.MuiGridLegacy-spacing-xs-9 | spacing-xs-9 | |
.MuiGridLegacy-wrap-xs-nowrap | wrap-xs-nowrap | 如果 wrap="nowrap" ,套用至根元素的樣式。 |
.MuiGridLegacy-wrap-xs-wrap-reverse | wrap-xs-wrap-reverse | 如果 wrap="reverse" ,套用至根元素的樣式。 |
.MuiGridLegacy-zeroMinWidth | zeroMinWidth | 如果 zeroMinWidth={true} ,套用至根元素的樣式。 |
您可以使用以下自訂選項之一來覆寫元件的樣式
- 使用 `全域類別名稱`。
- 在自訂主題中使用規則名稱作為元件 ``styleOverrides` 屬性` 的一部分。
原始碼
如果您在此頁面中找不到資訊,請考慮查看 `元件的實作` 以取得更多詳細資訊。