|
| 1 | +# CSS Grid with Angular Layout |
| 2 | + |
| 3 | +### Introduction |
| 4 | + |
| 5 | +CSS Grid is a relatively new, powerful layout library available in all evergreen browsers. It provides |
| 6 | +an extra level of dimensionality for constructing web layouts compared to Flexbox. We have added 11 new |
| 7 | +directives with responsive functionality to the Angular Layout library to enable developers to easily add |
| 8 | +the new engine to their apps. |
| 9 | + |
| 10 | +### Usage |
| 11 | + |
| 12 | +The new suite of directives is extensive, and covers the majority of CSS Grid functionality. The |
| 13 | +following table shows the parity between directives and CSS properties: |
| 14 | + |
| 15 | +| Grid Directive | CSS Property(s) | Extra Inputs | |
| 16 | +| ---------------- |:-----------------------------------------:| --------------------------:| |
| 17 | +| `gdAlignColumns` | `align-content` and `align-items` | `gdInline` for inline-grid | |
| 18 | +| `gdAlignRows` | `justify-content` and `justify-items` | `gdInline` for inline-grid | |
| 19 | +| `gdArea` | `grid-area` | none | |
| 20 | +| `gdAreas` | `grid-areas` | `gdInline` for inline-grid | |
| 21 | +| `gdAuto` | `grid-auto-flow` | `gdInline` for inline-grid | |
| 22 | +| `gdColumn` | `grid-column` | none | |
| 23 | +| `gdColumns` | `grid-template-columns` | `gdInline` for inline-grid<br>`!` at the end means `grid-auto-columns` | |
| 24 | +| `gdGap` | `grid-gap` | `gdInline` for inline-grid | |
| 25 | +| `gdGridAlign` | `justify-self` and `align-self` | none | |
| 26 | +| `gdRow` | `grid-row` | none | |
| 27 | +| `gdRows` | `grid-template-rows` | `gdInline` for inline-grid<br>`!` at the end means `grid-auto-rows` | |
| 28 | + |
| 29 | +Note: unless otherwise specified, the above table represents exact parity. The inputs for the |
| 30 | +directives will be mapped verbatim to the CSS property without sanitization |
| 31 | + |
| 32 | +### Limitations |
| 33 | + |
| 34 | +While CSS Grid has excellent cross-browser and mobile support, it is currently unsupported in IE11 |
| 35 | +due to an outdated spec implementation |
| 36 | + |
| 37 | +### Using with Flexbox |
| 38 | + |
| 39 | +The new CSS Grid directives can be used in concert with the existing Flexbox directives seamlessly. |
| 40 | +Simply import the top-level `FlexLayoutModule`, or both `FlexModule` and `GridModule` as follows: |
| 41 | + |
| 42 | +```typescript |
| 43 | +import {FlexLayoutModule} from '@angular/flex-layout'; |
| 44 | +``` |
| 45 | + |
| 46 | +```typescript |
| 47 | +import {FlexModule} from '@angular/flex-layout/flex'; |
| 48 | +import {GridModule} from '@angular/flex-layout/grid'; |
| 49 | +``` |
| 50 | + |
| 51 | +This allows you to use, for example, Flexbox inside a CSS Grid as follows: |
| 52 | + |
| 53 | +```html |
| 54 | +<div gdAuto> |
| 55 | + <div fxLayout="row"> |
| 56 | + <div fxFlex></div> |
| 57 | + </div> |
| 58 | +</div> |
| 59 | +``` |
| 60 | + |
| 61 | +### References |
| 62 | + |
| 63 | +The design doc for this part of the library can be found |
| 64 | +[here](https://docs.google.com/document/d/1YjKHAV7-wh5UZd4snoyw6bVWe1X5JF-zDaUFa8-JDtE) |
0 commit comments