mdc-utility-styles v0.1.0-alpha.3
mdc-css-utils
This package is inspired by Bootstrap utility styles and implements very similar set of CSS classes for Material Components for web (MDC).
Why not use Bootstrap's utility styles? Or some stand-alone package?
Nothing prevents from using some other utility styles package because MDC is highly compatible with other frameworks. However there are these reasons why you might need this package: 1. Often Material design apps don't use Bootstrap, but you still need those utility styles. 2. Other packages has their own breakpoints system.
Styles
Class naming
Class names are basically the same as in Bootstrap, with a little bit of MDC flavor. Lets review an example: .mdx-d--flex-desktop
:
- Class name starts with
.mdx-
prefix. mdx stands for Material Design Extensions. Having prefix makes it easy finding all usages of this package. d--flex
corresponds with Bootstrap'sd-flex
. But since we follow BEM naming, we separateflex
with double dash. BEM naming is used to be inline with other MDC packages.- At the end there is optional
-desktop
,-tablet
or-phone
. It is basically similar tolg
,md
andsm
in Bootstrap, but follows MDC pattern for naming such classes.
Breakpoints:
phone
tablet
desktop
Classes without breakpoint apply to all breakpoints.
Styles behavior is very similar to Bootstrap's Utility styles with a few differences:
- in Bootstrap class with breakpoint applies to the breakpoint and above breakpoints. In MDC class with breakpoint applies to specified breakpoint only.
Here is list of CSS classes:
CSS Class | Description |
---|---|
mdx-d--<VALUE> mdx-d--<VALUE>-<DEVICE> | Change the value of the display CSS property.VALUE: none, inline, inline-block, block, grid, table, table-cell, table-row, flex, inline-flex.Examples:mdx-d--flex mdx-d--flex-tablet Bootstrap Docs: Display |
mdx-p--<N> mdx-p--<N>-<DEVICE> mdx-pt--<N> mdx-pt--<N>-<DEVICE> mdx-pr--<N> mdx-pr--<N>-<DEVICE> mdx-pb--<N> mdx-pb--<N>-<DEVICE> mdx-pl--<N> mdx-pl--<N>-<DEVICE> mdx-px--<N> mdx-px--<N>-<DEVICE> mdx-py--<N> mdx-py--<N>-<DEVICE> | Classes that set padding .N - value from 0 to 5. Each step is 8px.Examples:mdx-p--2 mdx-p--2-tablet mdx-pt--1 mdx-pt--1-desktop mdx-px--2 mdx-px--2-desktop Bootstrap Docs: Spacing. Margin and padding |
mdx-m--<N> mdx-m--<N>-<DEVICE> mdx-mt--<N> mdx-mt--<N>-<DEVICE> mdx-mr--<N> mdx-mr--<N>-<DEVICE> mdx-mb--<N> mdx-mb--<N>-<DEVICE> mdx-ml--<N> mdx-ml--<N>-<DEVICE> mdx-mx--<N> mdx-mx--<N>-<DEVICE> mdx-my--<N> mdx-my--<N>-<DEVICE> | Classes that set margin .N - value from 0 to 5. Each step is 8px.Examples:mdx-m--2 mdx-m--2-tablet mdx-mt--1 mdx-mt--1-desktop mdx-mx--2 mdx-mx--2-desktop Bootstrap Docs: Spacing. Margin and padding |
mdx-border--<SIDE> mdx-border--<SIDE>-<DEVICE> | Classes to add or remove an element’s borders. Border is always 1px solid. Color equals to Data table's stroke color.SIDE: bottom, top, left, right.Examples:mdx-border--top mdx-border--bottom-tablet Bootstrap Docs: Borders |
mdx-theme--<COLOR_STYLE>-<EMPHASIS> | MDC has a set of classes to set text color: mdc-theme--primary , mdc-theme--secondary , etc. These new classes extend the set with variations of main theme colors: high, medium, disabled. It is achieved by applying emphasis opacity on target color.COLOR_STYLE: primary, on-primary, secondary, on-secondary, on-surface.EMPHASIS: high, medium, disabled.Examples:mdx-theme--primary-medium mdx-theme--secondary-disabled |
Flex utility CSS classes
CSS Class | Description |
---|---|
mdx-flex-grow--<VALUE> mdx-flex-grow--<VALUE>-<DEVICE> | Use these utilities to toggle a flex item’s ability to grow to fill available space.VALUE: 0 or 1.Examples:mdx-flex-grow--1 mdx-flex-grow--0 mdx-flex-grow--0-tablet Bootstrap Docs: Grow and shrink |
mdx-flex-shrink--<VALUE> mdx-flex-shrink--<VALUE>-<DEVICE> | Use these utilities to toggle a flex item’s ability to shrink if necessary.VALUE: 0 or 1.Examples:mdx-flex-shrink--1 mdx-flex-shrink--0 mdx-flex-shrink--0-tablet Bootstrap Docs: Grow and shrink |
mdx-align-items--<ALIGN> mdx-align-items--<ALIGN>-<DEVICE> | ALIGN: start, end, center, baseline, stretch.Examples:mdx-align-items--center mdx-align-items--center-phone |
Display
Change the value of the display
property. The classes are named using the format:
.mdx-d--{value}
.mdx-d--{value}-{breakpoint}
Where value is one of:
none
inline
inline-block
block
grid
table
table-cell
table-row
flex
inline-flex
Examples: .mdx-d--flex .mdx-d--none-desktop
- sets display:flex
, but hides the element on desktop screen size.
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago