UNPKG

3.57 kBTypeScriptView Raw
1import { SxProps, SystemProps } from '@mui/system';
2import { OverridableComponent, OverrideProps } from '@mui/types';
3import { Theme, Breakpoint } from '../styles';
4export type Grid2Slot = 'root';
5type ResponsiveStyleValue<T> = T | Array<T | null> | {
6 [key in Breakpoint]?: T | null;
7};
8export type GridDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
9export type GridSpacing = number | string;
10export type GridWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
11export type GridSize = 'auto' | 'grow' | number | false;
12export type GridOffset = 'auto' | number;
13export interface GridBaseProps {
14 /**
15 * The content of the component.
16 */
17 children?: React.ReactNode;
18 /**
19 * The number of columns.
20 * @default 12
21 */
22 columns?: ResponsiveStyleValue<number>;
23 /**
24 * Defines the horizontal space between the type `item` components.
25 * It overrides the value of the `spacing` prop.
26 */
27 columnSpacing?: ResponsiveStyleValue<GridSpacing>;
28 /**
29 * If `true`, the component will have the flex *container* behavior.
30 * You should be wrapping *items* with a *container*.
31 * @default false
32 */
33 container?: boolean;
34 /**
35 * Defines the `flex-direction` style property.
36 * It is applied for all screen sizes.
37 * @default 'row'
38 */
39 direction?: ResponsiveStyleValue<GridDirection>;
40 /**
41 * Defines the offset value for the type `item` components.
42 */
43 offset?: ResponsiveStyleValue<GridOffset>;
44 /**
45 * @internal
46 * The level of the grid starts from `0` and increases when the grid nests
47 * inside another grid. Nesting is defined as a container Grid being a direct
48 * child of a container Grid.
49 *
50 * ```js
51 * <Grid container> // level 0
52 * <Grid container> // level 1
53 * <Grid container> // level 2
54 * ```
55 *
56 * Only consecutive grid is considered nesting. A grid container will start at
57 * `0` if there are non-Grid container element above it.
58 *
59 * ```js
60 * <Grid container> // level 0
61 * <div>
62 * <Grid container> // level 0
63 * ```
64 *
65 * ```js
66 * <Grid container> // level 0
67 * <Grid>
68 * <Grid container> // level 0
69 * ```
70 */
71 unstable_level?: number;
72 /**
73 * Defines the vertical space between the type `item` components.
74 * It overrides the value of the `spacing` prop.
75 */
76 rowSpacing?: ResponsiveStyleValue<GridSpacing>;
77 /**
78 * Defines the size of the the type `item` components.
79 */
80 size?: ResponsiveStyleValue<GridSize>;
81 /**
82 * Defines the space between the type `item` components.
83 * It can only be used on a type `container` component.
84 * @default 0
85 */
86 spacing?: ResponsiveStyleValue<GridSpacing> | undefined;
87 /**
88 * Defines the `flex-wrap` style property.
89 * It's applied for all screen sizes.
90 * @default 'wrap'
91 */
92 wrap?: GridWrap;
93}
94export interface Grid2TypeMap<P = {}, D extends React.ElementType = 'div'> {
95 props: P & GridBaseProps & {
96 sx?: SxProps<Theme>;
97 } & SystemProps<Theme>;
98 defaultComponent: D;
99}
100export type Grid2Props<D extends React.ElementType = Grid2TypeMap['defaultComponent'], P = {
101 component?: React.ElementType;
102}> = OverrideProps<Grid2TypeMap<P, D>, D>;
103/**
104 *
105 * Demos:
106 *
107 * - [Grid version 2](https://mui.com/material-ui/react-grid2/)
108 *
109 * API:
110 *
111 * - [Grid2 API](https://mui.com/material-ui/api/grid-2/)
112 */
113declare const Grid2: OverridableComponent<Grid2TypeMap>;
114export default Grid2;