|
1 | | -## Responsive breakpoints |
| 1 | +Smooth UI has a powerful grid system to layout an align content. It's build with [flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes), mobile first and fully responsive. |
2 | 2 |
|
3 | | -Using `xs`, `sm`, `md`, `lg` and `xl` you can set size using responsive breakpoints. |
| 3 | +```js |
| 4 | +<Row> |
| 5 | + <Col sm>One</Col> |
| 6 | + <Col sm>Two</Col> |
| 7 | + <Col sm>Three</Col> |
| 8 | +</Row> |
| 9 | +``` |
| 10 | + |
| 11 | +The above example creates three equal-width columns on small, medium, large, and extra large devices. |
| 12 | + |
| 13 | +### Breakpoints |
| 14 | + |
| 15 | +This table resume all available breakpoints in grid. |
| 16 | + |
| 17 | +<table> |
| 18 | + <thead> |
| 19 | + <tr> |
| 20 | + <th></th> |
| 21 | + <th> |
| 22 | + Extra small<br> |
| 23 | + <small><576px</small> |
| 24 | + </th> |
| 25 | + <th> |
| 26 | + Small<br> |
| 27 | + <small>≥576px</small> |
| 28 | + </th> |
| 29 | + <th> |
| 30 | + Medium<br> |
| 31 | + <small>≥768px</small> |
| 32 | + </th> |
| 33 | + <th> |
| 34 | + Large<br> |
| 35 | + <small>≥992px</small> |
| 36 | + </th> |
| 37 | + <th> |
| 38 | + Extra large<br> |
| 39 | + <small>≥1200px</small> |
| 40 | + </th> |
| 41 | + </tr> |
| 42 | + </thead> |
| 43 | + <tbody> |
| 44 | + <tr> |
| 45 | + <th>Max container width</th> |
| 46 | + <td>None (auto)</td> |
| 47 | + <td>540px</td> |
| 48 | + <td>720px</td> |
| 49 | + <td>960px</td> |
| 50 | + <td>1140px</td> |
| 51 | + </tr> |
| 52 | + <tr> |
| 53 | + <th>Prop</th> |
| 54 | + <td><code>xs</code></td> |
| 55 | + <td><code>sm</code></td> |
| 56 | + <td><code>md</code></td> |
| 57 | + <td><code>lg</code></td> |
| 58 | + <td><code>xl</code></td> |
| 59 | + </tr> |
| 60 | + </tbody> |
| 61 | +</table> |
| 62 | + |
| 63 | +### Auto-layout columns |
| 64 | + |
| 65 | +#### Equal-width |
| 66 | + |
| 67 | +For example, here are two grid layouts that apply to every device and viewport, from `xs` to `xl`. Add any number of unit-less props for each breakpoint you need and every column will be the same width. |
| 68 | + |
| 69 | +```js |
| 70 | + <Row> |
| 71 | + <Col>1 of 2</Col> |
| 72 | + <Col>2 of 2</Col> |
| 73 | + </Row> |
| 74 | + <Row> |
| 75 | + <Col>1 of 3</Col> |
| 76 | + <Col>2 of 3</Col> |
| 77 | + <Col>3 of 3</Col> |
| 78 | + </Row> |
| 79 | +``` |
| 80 | + |
| 81 | +#### Setting one column width |
| 82 | + |
| 83 | +Auto-layout for flexbox grid columns also means you can set the width of one column and have the sibling columns automatically resize around it. |
| 84 | + |
| 85 | +```js |
| 86 | + <Row> |
| 87 | + <Col>1 of 3</Col> |
| 88 | + <Col xs={6}>2 of 3 (wider)</Col> |
| 89 | + <Col>3 of 3</Col> |
| 90 | + </Row> |
| 91 | + <Row> |
| 92 | + <Col>1 of 3</Col> |
| 93 | + <Col xs={5}>2 of 3 (wider)</Col> |
| 94 | + <Col>3 of 3</Col> |
| 95 | + </Row> |
| 96 | +``` |
| 97 | + |
| 98 | +### Responsive classes |
| 99 | + |
| 100 | +Smooth UI's grid includes five tiers of predefined classes for building complex responsive layouts. Customize the size of your columns on extra small, small, medium, large, or extra large devices however you see fit. |
| 101 | + |
| 102 | +#### All breakpoints |
| 103 | + |
| 104 | +For grids that are the same from the smallest of devices to the largest, use the props `xs`, `sm`, `md`, `lg` or `xl`. Specify a number value when you need a particularly sized column; otherwise, feel free to put the prop without a value (`true`). |
| 105 | + |
| 106 | +```js |
| 107 | + <Row> |
| 108 | + <Col>-</Col> |
| 109 | + <Col>-</Col> |
| 110 | + <Col>-</Col> |
| 111 | + <Col>-</Col> |
| 112 | + </Row> |
| 113 | + <Row> |
| 114 | + <Col xs={8}>{`xs={8}`}</Col> |
| 115 | + <Col xs={4}>{`xs={4}`}</Col> |
| 116 | + </Row> |
| 117 | +``` |
| 118 | + |
| 119 | +#### Stacked to horizontal |
| 120 | + |
| 121 | +Using a single set of `sm` props, you can create a basic grid system that starts out stacked before becoming horizontal with at the small breakpoint (`sm`). |
| 122 | + |
| 123 | +```js |
| 124 | + <Row> |
| 125 | + <Col sm={8}>{`sm={8}`}</Col> |
| 126 | + <Col sm={4}>{`sm={4}`}</Col> |
| 127 | + </Row> |
| 128 | + <Row> |
| 129 | + <Col sm>sm</Col> |
| 130 | + <Col sm>sm</Col> |
| 131 | + <Col sm>sm</Col> |
| 132 | + </Row> |
| 133 | +``` |
| 134 | + |
| 135 | +#### Mix and match |
| 136 | + |
| 137 | +Don’t want your columns to simply stack in some grid tiers? Use a combination of different props for each tier as needed. See the example below for a better idea of how it all works. |
| 138 | + |
| 139 | +**Stack the columns on mobile by making one full-width and the other half-width** |
| 140 | + |
| 141 | +```js |
| 142 | +<Row> |
| 143 | + <Col xs={12} md={8}>{`xs={12} md={8}`}</Col> |
| 144 | + <Col xs={6} md={4}>{`xs={6} md={4}`}</Col> |
| 145 | +</Row> |
| 146 | +``` |
| 147 | + |
| 148 | +**Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop** |
4 | 149 |
|
5 | 150 | ```js |
6 | 151 | <Row> |
7 | | - <Col xs style={{ border: '1px solid black' }}> |
8 | | - 1 |
| 152 | + <Col xs={6} md={4}> |
| 153 | + {`xs={6} md={4}`} |
9 | 154 | </Col> |
10 | | - <Col xs style={{ border: '1px solid black' }}> |
11 | | - 2 |
| 155 | + <Col xs={6} md={4}> |
| 156 | + {`xs={6} md={4}`} |
12 | 157 | </Col> |
| 158 | + <Col xs={6} md={4}> |
| 159 | + {`xs={6} md={4}`} |
| 160 | + </Col> |
| 161 | +</Row> |
| 162 | +``` |
| 163 | + |
| 164 | +**Columns are always 50% wide, on mobile and desktop** |
| 165 | + |
| 166 | +```js |
| 167 | +<Row> |
| 168 | + <Col xs={6}>{`xs={6}`}</Col> |
| 169 | + <Col xs={6}>{`xs={6}`}</Col> |
| 170 | +</Row> |
| 171 | +``` |
| 172 | + |
| 173 | +### Custom gutter |
| 174 | + |
| 175 | +It is possible to specify custom padding (left and right) using `gutter` props on `Row`. |
| 176 | + |
| 177 | +```js |
| 178 | +<Row gutter={5}> |
| 179 | + <React.Fragment> |
| 180 | + <Col>{`5px gutter`}</Col> |
| 181 | + <Col>{`5px gutter`}</Col> |
| 182 | + <Col>{`5px gutter`}</Col> |
| 183 | + </React.Fragment> |
13 | 184 | </Row> |
14 | 185 | ``` |
0 commit comments