MatGridList
Themat-grid-list is a two-dimensional list view that arranges cells into grid-based layout. It supports dynamic tile sizing and automatic layout.
Basic Usage
API Reference
MatGridList
Selector:mat-grid-list
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
cols | number | - | Required Number of columns in the grid list |
rowHeight | string | number | '1:1' | Row height. Can be a number (px), ratio (e.g., ‘4:3’), or ‘fit’ |
gutterSize | string | '1px' | Size of the grid list’s gutter in pixels |
MatGridTile
Selector:mat-grid-tile
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
colspan | number | 1 | Number of columns the tile spans |
rowspan | number | 1 | Number of rows the tile spans |
MatGridTileHeader
Selector:mat-grid-tile-header
Header section for a grid tile.
MatGridTileFooter
Selector:mat-grid-tile-footer
Footer section for a grid tile.
Examples
Fixed Row Height
Ratio Row Height
Fit Mode
Spanning Tiles
With Headers and Footers
Image Gallery
Dynamic Grid
Complex Layout
Row Height Modes
Fixed Height
Set an explicit pixel value:Ratio
Set a width:height ratio:Fit
Divide available height by number of rows:Accessibility
The grid list has proper ARIA roles applied. Add appropriate labels:Styling
Tile Styling
Header and Footer Styling
Gutter Styling
ThegutterSize input controls spacing:
Performance Considerations
- Virtual scrolling: For large lists, consider using CDK virtual scrolling
- Image optimization: Use appropriate image sizes and lazy loading
- Change detection: Use
OnPushstrategy when possible
Best Practices
- Consistent sizing: Keep tiles consistently sized for better visual appeal
- Responsive design: Adjust column count based on screen size
- Gutter spacing: Use appropriate gutter size for visual separation
- Content overflow: Handle content that doesn’t fit within tiles
- Loading states: Show placeholders while content loads