Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@material/layout-grid
Advanced tools
MDC layout grid is a CSS-only component that implements the Material Design layout grid guidelines, and makes them available to developers as CSS classes and Sass mixins.
It uses CSS Grid where possible, with a CSS Flexible Box fallback everywhere else.
npm install --save @material/layout-grid
A grid consists of a group of cells, which get positioned in sequence according to a predefined number of columns. Cells specify how many columns to span (the default being 4), and get placed side by side while there is room. When there isn't enough room for a cell, it gets moved to the beginning of the next row, and placement continues as usual.
The grid has 12 columns in desktop mode (>= 840px), 8 columns in tablet mode (>= 480px), and 4 columns in phone mode (< 480px). Column widths are variable; margins and gutters are fixed, with columns taking up the remainder of the space.
Margins (the space between the edge of the grid and the edge of the first cell) and gutters (the space between edges of adjacent cells) are user-definable, with the Material Design spec recommending 8px, 16px, 24px or 40px as the sizes to choose from. The default margin and gutter are both 16px, but they don't have to be the same size.
The grid and cells are not styled in any way, serving only for alignment and positioning of elements.
<div class="mdc-layout-grid">
<div class="mdc-layout-grid__cell"></div>
<div class="mdc-layout-grid__cell"></div>
<div class="mdc-layout-grid__cell"></div>
</div>
The grid should have the mdc-layout-grid
class, and every cell should have the mdc-layout-grid__cell
class.
Behavior for grids containing direct children without the mdc-layout-grid__cell
class is undefined.
The default size for both the margins and gutters in MDC layout grid is 16px.
You can change the margins and gutters for a grid using the --mdc-layout-grid-margin
and --mdc-layout-grid-gutter
custom properties, respectively. This requires support for CSS custom properties on the end-user's browser.
The Material Design spec recommends 8px, 16px, 24px or 40px as the sizes to choose from, but MDC layout grid doesn't impose any restrictions.
.my-grid {
--mdc-layout-grid-margin: 40px;
--mdc-layout-grid-gutter: 16px;
}
Note: Due to the implementation of MDC layout grid, it's not possible to use a margin smaller than half of the size of the gutter, in most browsers. As support for CSS Grid lands in browsers, this limitation will go away, as MDC layout grid is progressively enhanced to support it.
<div class="mdc-layout-grid">
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-6"></div>
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-4"></div>
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2"></div>
</div>
Cells have a default span size of 4 columns, with other sizes being possible by applying one of the span classes, of the
form mdc-layout-grid__cell--span-{columns}
, where {columns}
is an integer between 1 and 12.
If the chosen span size is larger than the available number of columns at the current screen size, the cell behaves as if its chosen span size were equal to the available number of columns at that screen size. That is, it takes up the entirety of its row, and no more than that.
It's possible to tweak the behavior of cells further by defining different column spans for specific screen sizes. These override the default at that size.
You can do that with the mdc-layout-grid__cell--span-{columns}-{screen_size}
classes, where {columns}
is an integer
between 1 and 12 and {screen_size}
is one of desktop
, tablet
or phone
.
<div class="mdc-layout-grid">
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-6 mdc-layout-grid__cell--span-8-tablet"></div>
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-4 mdc-layout-grid__cell--span-6-tablet"></div>
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2 mdc-layout-grid__cell--span-4-phone"></div>
</div>
In the example above, the first cell has a default span of 6, the second 4, and the third 2. However, at tablet sizes, the first cell becomes 8 columns wide instead, and the second 6 columns wide. At phone sizes, the third cell becomes 4 columns wide.
By default, items are positioned in the source order. However, you can reorder them by using the
mdc-layout-grid__cell--order-{number}
classes, where {order}
is an integer between 1 and 12.
<div class="mdc-layout-grid">
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--order-3"></div>
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--order-1"></div>
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--order-2"></div>
</div>
Please bear in mind that this may have an impact on accessibility, since screen readers and other tools tend to follow source order.
Items are defined to stretch, by default, taking up the height of their corresponding row. You can switch to a different
behavior by using one of the mdc-layout-grid__cell--align-{position}
alignment classes, where {position}
is one of
{top}
, {middle}
or {bottom}
.
<div class="mdc-layout-grid">
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--align-top"></div>
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--align-middle"></div>
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--align-bottom"></div>
</div>
@include mdc-layout-grid(16px, 16px, 1600px);
mdc-layout-grid
defines a grid and should be applied to the container element. The mixin takes three parameters:
$margin
: the size of the grid margin.$gutter
: the size of the gutter between cells.$max-width
(optional): the maximum width of the grid, at which point space stops being distributed by the columns.Note that the margin and gutter can be overriden at runtime by using the CSS custom properties detailed in the "Margins and gutters" section under "CSS class usage".
@include mdc-layout-grid-cell(16px, 4);
mdc-layout-grid-cell
defines a cell and should be applied to the cell element. The mixin takes two parameters:
$gutter
: the size of the gutter between cells. Be sure to use the same value as for the parent grid.$span
(optional, default 4): how many columns this cell should span (1 to 12).@include mdc-layout-grid-cell(16px);
@include mdc-layout-grid-cell-order(2);
mdl-layout-grid-cell-order
reorders a cell inside a grid. It's an optional mixin that should be applied to the cell
element, together with the mandatory mdc-layout-grid-cell
.
It takes a single parameter, $order
, which expects a value from 1 to 12.
@include mdc-layout-grid-cell(16px);
@include mdc-layout-grid-cell-align(top);
mdl-layout-grid-cell-align
aligns a cell vertically inside a grid. It's an optional mixin that should be applied to
the cell element, together with the mandatory mdc-layout-grid-cell
.
It takes a single parameter, $position
, which expects top
, middle
or bottom
as values.
FAQs
The Material Components for the web layout grid component
The npm package @material/layout-grid receives a total of 607,369 weekly downloads. As such, @material/layout-grid popularity was classified as popular.
We found that @material/layout-grid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.