UNPKG

5.1 kBTypeScriptView Raw
1import * as React from 'react';
2import { Breakpoint } from '../styles/createBreakpoints';
3import { OverridableComponent, SimplifiedPropsOf, OverrideProps } from '../OverridableComponent';
4
5export type GridItemsAlignment = 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
6
7export type GridContentAlignment =
8 | 'stretch'
9 | 'center'
10 | 'flex-start'
11 | 'flex-end'
12 | 'space-between'
13 | 'space-around';
14
15export type GridDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
16
17export type GridSpacing = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
18
19export type GridJustification =
20 | 'flex-start'
21 | 'center'
22 | 'flex-end'
23 | 'space-between'
24 | 'space-around'
25 | 'space-evenly';
26
27export type GridWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
28
29export type GridSize = 'auto' | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
30
31export type GridClassKey =
32 | 'root'
33 | 'container'
34 | 'item'
35 | 'zeroMinWidth'
36 | 'direction-xs-column'
37 | 'direction-xs-column-reverse'
38 | 'direction-xs-row-reverse'
39 | 'wrap-xs-nowrap'
40 | 'wrap-xs-wrap-reverse'
41 | 'align-items-xs-center'
42 | 'align-items-xs-flex-start'
43 | 'align-items-xs-flex-end'
44 | 'align-items-xs-baseline'
45 | 'align-content-xs-center'
46 | 'align-content-xs-flex-start'
47 | 'align-content-xs-flex-end'
48 | 'align-content-xs-space-between'
49 | 'align-content-xs-space-around'
50 | 'justify-content-xs-center'
51 | 'justify-content-xs-flex-end'
52 | 'justify-content-xs-space-between'
53 | 'justify-content-xs-space-around'
54 | 'justify-content-xs-space-evenly'
55 | 'spacing-xs-1'
56 | 'spacing-xs-2'
57 | 'spacing-xs-3'
58 | 'spacing-xs-4'
59 | 'spacing-xs-5'
60 | 'spacing-xs-6'
61 | 'spacing-xs-7'
62 | 'spacing-xs-8'
63 | 'spacing-xs-9'
64 | 'spacing-xs-10'
65 | 'grid-xs-auto'
66 | 'grid-xs-true'
67 | 'grid-xs-1'
68 | 'grid-xs-2'
69 | 'grid-xs-3'
70 | 'grid-xs-4'
71 | 'grid-xs-5'
72 | 'grid-xs-6'
73 | 'grid-xs-7'
74 | 'grid-xs-8'
75 | 'grid-xs-9'
76 | 'grid-xs-10'
77 | 'grid-xs-11'
78 | 'grid-xs-12';
79
80export interface GridTypeMap<P = {}, D extends React.ElementType = 'div'> {
81 props: P & {
82 /**
83 * Defines the `align-content` style property.
84 * It's applied for all screen sizes.
85 */
86 alignContent?: GridContentAlignment;
87 /**
88 * Defines the `align-items` style property.
89 * It's applied for all screen sizes.
90 */
91 alignItems?: GridItemsAlignment;
92 /**
93 * The content of the component.
94 */
95 children?: React.ReactNode;
96 /**
97 * If `true`, the component will have the flex *container* behavior.
98 * You should be wrapping *items* with a *container*.
99 */
100 container?: boolean;
101 /**
102 * Defines the `flex-direction` style property.
103 * It is applied for all screen sizes.
104 */
105 direction?: GridDirection;
106 /**
107 * If `true`, the component will have the flex *item* behavior.
108 * You should be wrapping *items* with a *container*.
109 */
110 item?: boolean;
111 /**
112 * Defines the `justify-content` style property.
113 * It is applied for all screen sizes.
114 * @deprecated Use `justifyContent` instead, the prop was renamed
115 */
116 justify?: GridJustification;
117 /**
118 * Defines the `justify-content` style property.
119 * It is applied for all screen sizes.
120 */
121 justifyContent?: GridJustification;
122 /**
123 * Defines the number of grids the component is going to use.
124 * It's applied for the `lg` breakpoint and wider screens if not overridden.
125 */
126 lg?: boolean | GridSize;
127 /**
128 * Defines the number of grids the component is going to use.
129 * It's applied for the `md` breakpoint and wider screens if not overridden.
130 */
131 md?: boolean | GridSize;
132 /**
133 * Defines the number of grids the component is going to use.
134 * It's applied for the `sm` breakpoint and wider screens if not overridden.
135 */
136 sm?: boolean | GridSize;
137 /**
138 * Defines the space between the type `item` component.
139 * It can only be used on a type `container` component.
140 */
141 spacing?: GridSpacing;
142 /**
143 * Defines the `flex-wrap` style property.
144 * It's applied for all screen sizes.
145 */
146 wrap?: GridWrap;
147 /**
148 * Defines the number of grids the component is going to use.
149 * It's applied for the `xl` breakpoint and wider screens.
150 */
151 xl?: boolean | GridSize;
152 /**
153 * Defines the number of grids the component is going to use.
154 * It's applied for all the screen sizes with the lowest priority.
155 */
156 xs?: boolean | GridSize;
157 /**
158 * If `true`, it sets `min-width: 0` on the item.
159 * Refer to the limitations section of the documentation to better understand the use case.
160 */
161 zeroMinWidth?: boolean;
162 };
163 defaultComponent: D;
164 classKey: GridClassKey;
165}
166
167/**
168 *
169 * Demos:
170 *
171 * - [Grid](https://mui.com/components/grid/)
172 *
173 * API:
174 *
175 * - [Grid API](https://mui.com/api/grid/)
176 */
177declare const Grid: OverridableComponent<GridTypeMap>;
178
179export type GridProps<
180 D extends React.ElementType = GridTypeMap['defaultComponent'],
181 P = {}
182> = OverrideProps<GridTypeMap<P, D>, D>;
183
184export default Grid;