
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@material/grid-list
Advanced tools
The existing MDCGridList component and styles will be removed in a future release. Some of its functionality
will be available in the MDC Image List package instead. Bugs and feature requests
will no longer be accepted for the mdc-grid-list package. It is recommended that you migrate to the
mdc-image-list package to continue to receive new features and updates.
MDC Grid List provides a RTL-aware Material Design Grid list component adhering to the Material Design Grid list spec. Grid Lists are best suited for presenting homogeneous data, typically images. Each item in a grid list is called a tile. Tiles maintain consistent width, height, and padding across screen sizes.
npm install @material/grid-list
Basic Grid list has the following structure:
<div class="mdc-grid-list">
<ul class="mdc-grid-list__tiles">
<li class="mdc-grid-tile">
<div class="mdc-grid-tile__primary">
<img class="mdc-grid-tile__primary-content" src="my-image.jpg" />
</div>
<span class="mdc-grid-tile__secondary">
<span class="mdc-grid-tile__title">Title</span>
</span>
</li>
<li class="mdc-grid-tile">
<div class="mdc-grid-tile__primary">
<img class="mdc-grid-tile__primary-content" src="my-image.jpg" />
</div>
<span class="mdc-grid-tile__secondary">
<span class="mdc-grid-tile__title">Title</span>
</span>
</li>
</ul>
</div>
The above markup will give you a Grid list of tiles that:
You just need to put the content you want to load in src of
<img class="mdc-grid-tile__primary-content" src="..."/>. However, if your
assets don't have the same aspect ratio you as specified in the tile, it will
distort those assets. We provide a solution of that case in
Using a div in place of an img section.
The tile width is set to 200px by default. There are three ways that you can overwrite the default value for your grid list:
.mdc-grid-tile {
--mdc-grid-list-tile-width: 300px;
}
You can overwrite the scss variable by
$mdc-grid-list-tile-width: 300px;
@import "@material/grid-list/mdc-grid-list";
<style>
.my-grid-list .mdc-grid-tile {
width : 300px;
}
</style>
<div class="mdc-grid-list my-grid-list">
<ul class="mdc-grid-list__tiles">
<li class="mdc-grid-tile"></li>
...
</ul>
</div>
Grid list tiles can have 1px padding instead of 4px by adding
mdc-grid-list--tile-gutter-1 modifier.
<div class="mdc-grid-list mdc-grid-list--tile-gutter-1">
<ul class="mdc-grid-list__tiles">
...
</ul>
</div>
Grid lists support image only tile. You can remove mdc-grid-tile__secondary
and create a image only grid list.
<div class="mdc-grid-list mdc-grid-list--tile-gutter-1">
<ul class="mdc-grid-list__tiles">
<li class="mdc-grid-tile">
<div class="mdc-grid-tile__primary">
<img class="mdc-grid-tile__primary-content" src="images/1-1.jpg" />
</div>
</li>
</ul>
</div>
Grid lists support header caption. You can change the footer caption to be a
header caption by adding mdc-grid-list--header-caption modifier.
<div class="mdc-grid-list mdc-grid-list--header-caption">
<ul class="mdc-grid-list__tiles">
...
</ul>
</div>
Grid lists support a one-line caption by default. You can add an additional line of support
text if needed by adding the mdc-grid-list--twoline-caption modifier and additional
markup
<div class="mdc-grid-list mdc-grid-list--twoline-caption">
<ul class="mdc-grid-list__tiles">
<li class="mdc-grid-tile">
<div class="mdc-grid-tile__primary">
<img class="mdc-grid-tile__primary-content" src="my-image.jpg" />
</div>
<span class="mdc-grid-tile__secondary">
<span class="mdc-grid-tile__title">Title</span>
<span class="mdc-grid-tile__support-text">Support text</span>
</span>
</li>
</ul>
</div>
You can add an icon to a caption by adding mdc-grid-list--with-icon-align-start or
mdc-grid-list--with-icon-align-end and changing the markup.
<div class="mdc-grid-list mdc-grid-list--with-icon-align-start">
<ul class="mdc-grid-list__tiles">
<li class="mdc-grid-tile">
<div class="mdc-grid-tile__primary">
<img class="mdc-grid-tile__primary-content" src="my-image.jpg" />
</div>
<span class="mdc-grid-tile__secondary">
<i class="mdc-grid-tile__icon material-icons">star_border</i>
<span class="mdc-grid-tile__title">Title</span>
</span>
</li>
</ul>
</div>
Grid list tiles support all material guideline recommended aspect ratio:
You can use the modifier class mdc-grid-list--tile-aspect-$ASPECT_RATIO to apply these aspect
ratios to your grid list. Simply replace $ASPECT_RATIO with any of the predefined ratios.
<!-- Example of 16x9 tile -->
<div class="mdc-grid-list mdc-grid-list--tile-aspect-16x9">
<ul class="mdc-grid-list__tiles">
...
</ul>
</div>
As pointed out in the previous section, if your assets don't have the same aspect ratio you as specified in the tile, it will distort those assets. We provide a solution of that case in Using a div in place of an img section.
In case you cannot ensure all your assets will have the same aspect ratio, you
can use div instead of img markup. It will resize the assets to cover the tile
and crop the assets to display the center part.
<style>
.my-tile-image {
background-image: url(my-image.jpg);
}
</style>
<div class="mdc-grid-list">
<ul class="mdc-grid-list__tiles">
<li class="mdc-grid-tile">
<div class="mdc-grid-tile__primary">
<div class="mdc-grid-tile__primary-content my-tile-image"></div>
</div>
<span class="mdc-grid-tile__secondary">
<span class="mdc-grid-tile__title">Title</span>
</span>
</li>
</ul>
</div>
However, the method results in a less semantic markup, so we don't use this method by default.
mdc-grid-list is automatically RTL-aware, and will re-position elements whenever
it, or its ancestors, have a dir="rtl" attribute.
mdc-grid-list supports theming. mdc-grid-tile__primary uses the theme's background
color for its background color. mdc-grid-tile__secondary uses the theme's primary
color for its background color, and the theme's on-primary color for its text color.
MDCGridListFoundation| Method Signature | Description |
|---|---|
alignCenter() => void | Centers tiles horizontally within their parent container. |
MDCGridListAdapter| Method Signature | Description |
|---|---|
getOffsetWidth() => number | Get root element mdc-grid-list offsetWidth. |
getNumberOfTiles() => number | Get the number of mdc-grid-tile elements contained within the grid list. |
getOffsetWidthForTileAtIndex(index: number) => number | Get offsetWidth of mdc-grid-tile at specified index. |
setStyleForTilesElement(property: string, value: number) => void | Set mdc-grid-list__tiles style property to provided value. |
registerResizeHandler(handler: EventListener) => void | Registers a handler to be called when the surface (or its viewport) resizes. Our default implementation adds the handler as a listener to the window's resize() event. |
deregisterResizeHandler(handler: EventListener) => void | Unregisters a handler to be called when the surface (or its viewport) resizes. Our default implementation removes the handler as a listener to the window's resize() event. |
FAQs
The Material Components for the web grid list component
The npm package @material/grid-list receives a total of 8,467 weekly downloads. As such, @material/grid-list popularity was classified as popular.
We found that @material/grid-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 17 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.