You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/pages/system/basics/basics.md
+25-16Lines changed: 25 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -132,7 +132,7 @@ The system provide direct access to the value in the theme. It makes it easier t
132
132
133
133
## The `sx` prop
134
134
135
-
The sx prop, as part of the system, solves these problems by providing a simple way of applying the correct design tokens for specific CSS properties directly to a React element. The [demo above](#demo) shows how it can be used in Material-UI components.
135
+
The `sx` prop, as part of the system, solves these problems by providing a simple way of applying the correct design tokens for specific CSS properties directly to a React element. The [demo above](#demo) shows how it can be used in Material-UI components.
136
136
137
137
This prop provides a superset of CSS that maps values directly from the theme, depending on the CSS property used. In addition, it allows a simple way of defining responsive values that correspond to the breakpoints defined in the theme.
138
138
@@ -162,41 +162,50 @@ There are lots of shorthands available for the CSS properties. Here are few exam
162
162
>
163
163
```
164
164
165
-
These are documented in the following sections.
165
+
These are documented in the following sections, for instance, [the spacing](/system/spacing/).
166
166
167
167
### Superset of CSS
168
168
169
169
As the prop supports a superset of CSS, you can use child or pseudo selectors, media queries, raw CSS values etc. Here are few examples:
170
170
171
-
```jsx
172
-
// Using pseudo selectors
171
+
- Using pseudo selectors:
172
+
173
+
```jsx
173
174
<Box
174
175
sx={{
175
176
// some styles
176
177
":hover": {
177
-
'& .ChildSelector': {
178
-
bgcolor:`${props.color}.dark`,
179
-
},
180
-
'& .OtherChildSelector': {
181
-
color:`${props.color}.dark`,
182
-
},
183
178
boxShadow:6,
184
179
},
185
180
}}
186
181
>
187
-
```
182
+
```
188
183
189
-
```jsx
190
-
// Using media queries
184
+
- Using media queries:
185
+
186
+
```jsx
191
187
<Box
192
188
sx={{
193
189
// some styles
194
-
"@media screen and (max-width: 992px)": {
190
+
'@media print': {
195
191
width:300,
196
192
},
197
193
}}
198
194
>
199
-
```
195
+
```
196
+
197
+
- Using nested selector:
198
+
199
+
```jsx
200
+
<Box
201
+
sx={{
202
+
// some styles
203
+
'& .ChildSelector': {
204
+
bgcolor:'primary.main',
205
+
},
206
+
}}
207
+
>
208
+
```
200
209
201
210
### Responsive values
202
211
@@ -301,7 +310,7 @@ const Div = styled('div')``;
301
310
>
302
311
> You should use this prop whenever you need to add or override a component style. If you find you are repeatedly applying the same styles to a component, then `styled()` may be a better option, as it allows you to specify the styles only once, and reuse them in all component instances. See [Customizing components](/customization/components/) for all the alternatives.
303
312
304
-
### 4. Babel plugin
313
+
### 4. Any element with the babel plugin
305
314
306
315
TODO [#23220](https://github.com/mui-org/material-ui/issues/23220).
0 commit comments