Skip to content

Commit 5ef0f9e

Browse files
improve docs
1 parent 2b1b6e0 commit 5ef0f9e

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

docs/src/pages/system/sizing/sizing.md

+29-12
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44

55
## Supported values
66

7-
The sizing style functions support different property input types:
7+
The sizing properties: `width`, `height`, `minHeight`, `maxHeight`, `minWidth` and `maxWidth` are using the following custom transform function for the value:
8+
9+
```js
10+
function transform(value) {
11+
return value <= 1 ? `${value * 100}%` : value;
12+
}
13+
```
14+
15+
If the value is between [0, 1], it's converted to percent.
16+
Otherwise, it is directly set on the CSS property.
817

918
{{"demo": "pages/system/sizing/Values.js", "defaultCodeOpen": false}}
1019

1120
```jsx
12-
// Numbers in [0,1] are multiplied by 100 and converted to % values.
13-
<Box sx={{ width: 1/4 }}>
21+
<Box sx={{ width: 1/4 }}> // Equivalent to width: '25%'
1422
<Box sx={{ width: 300 }}> // Numbers are converted to pixel values.
1523
<Box sx={{ width: '75%' }}> // String values are used as raw CSS.
1624
<Box sx={{ width: 1 }}> // 100%
@@ -28,6 +36,15 @@ The sizing style functions support different property input types:
2836
<Box sx={{ width: 'auto' }}>
2937
```
3038

39+
### Max-width
40+
41+
The max-width property allows setting a constraint on your breakpoints.
42+
In this example, the value resolves to [`theme.breakpoints.values.md`](/customization/default-theme/?expand-path=$.breakpoints.values).
43+
44+
```jsx
45+
<Box sx={{ maxWidth: 'md' }}>
46+
```
47+
3148
## Height
3249

3350
{{"demo": "pages/system/sizing/Height.js", "defaultCodeOpen": false}}
@@ -45,12 +62,12 @@ The sizing style functions support different property input types:
4562
import { sizing } from '@material-ui/system';
4663
```
4764

48-
| Import name | Prop | CSS property | Theme key |
49-
| :---------- | :---------- | :----------- | :-------- |
50-
| `width` | `width` | `width` | none |
51-
| `maxWidth` | `maxWidth` | `max-width` | none |
52-
| `minWidth` | `minWidth` | `min-width` | none |
53-
| `height` | `height` | `height` | none |
54-
| `maxHeight` | `maxHeight` | `max-height` | none |
55-
| `minHeight` | `minHeight` | `min-height` | none |
56-
| `boxSizing` | `boxSizing` | `box-sizing` | none |
65+
| Import name | Prop | CSS property | Theme key |
66+
| :---------- | :---------- | :----------- | :------------------------------------------------------------------------------------------- |
67+
| `width` | `width` | `width` | none |
68+
| `maxWidth` | `maxWidth` | `max-width` | [`theme.breakpoints.values`](/customization/default-theme/?expand-path=$.breakpoints.values) |
69+
| `minWidth` | `minWidth` | `min-width` | none |
70+
| `height` | `height` | `height` | none |
71+
| `maxHeight` | `maxHeight` | `max-height` | none |
72+
| `minHeight` | `minHeight` | `min-height` | none |
73+
| `boxSizing` | `boxSizing` | `box-sizing` | none |

docs/src/pages/system/the-sx-prop/the-sx-prop.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ function transform(value) {
111111
}
112112
```
113113

114-
Basically, if the value is between [0, 1] it is converted to percent, otherwise it is directly set on the CSS property.
114+
If the value is between [0, 1], it's converted to percent.
115+
Otherwise, it is directly set on the CSS property.
115116

116117
```jsx
117-
<Box sx={{ width: 0.5 }} /> // equivalent to width: '50%'
118+
<Box sx={{ width: 1/2 }} /> // equivalent to width: '50%'
118119
<Box sx={{ width: 20 }} /> // equivalent to width: '20px'
119120
```
120121

0 commit comments

Comments
 (0)