0.1.0-alpha.3 • Published 4 years ago

mdc-utility-styles v0.1.0-alpha.3

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

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:

  1. Class name starts with .mdx- prefix. mdx stands for Material Design Extensions. Having prefix makes it easy finding all usages of this package.
  2. d--flex corresponds with Bootstrap's d-flex. But since we follow BEM naming, we separate flex with double dash. BEM naming is used to be inline with other MDC packages.
  3. At the end there is optional -desktop, -tablet or -phone. It is basically similar to lg, md and sm 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--flexmdx-d--flex-tabletBootstrap 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--2mdx-p--2-tabletmdx-pt--1mdx-pt--1-desktopmdx-px--2mdx-px--2-desktopBootstrap 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--2mdx-m--2-tabletmdx-mt--1mdx-mt--1-desktopmdx-mx--2mdx-mx--2-desktopBootstrap 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--topmdx-border--bottom-tabletBootstrap 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-mediummdx-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--1mdx-flex-grow--0mdx-flex-grow--0-tabletBootstrap 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--1mdx-flex-shrink--0mdx-flex-shrink--0-tabletBootstrap Docs: Grow and shrink
mdx-align-items--<ALIGN>mdx-align-items--<ALIGN>-<DEVICE>ALIGN: start, end, center, baseline, stretch.Examples:mdx-align-items--centermdx-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.

0.1.0-alpha.4

4 years ago

0.1.0-alpha.3

4 years ago

0.1.0-alpha.2

4 years ago

0.1.0-alpha.1

4 years ago

0.1.0-alpha.0

4 years ago