1.2.2 • Published 6 years ago

react-material-responsive-grid v1.2.2

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

React Material Responsive Grid

A set of React components implementing the material-responsive-grid CSS framework.

Installation

npm i react-material-responsive-grid --save

Components

Grid

Container for Row components, intended as a layout

Features

  • Adheres to Material Design responsive UI standards for screens at or exceeding 1600 px
  • Fluid by default, allows the Grid to continue
  • Margin by default, preserves the outer padding for outer columns, preventing a row of content from spanning edge to edge
  • Optionally fixed width for viewports larger than 1599 px, centered or left aligned
  • Optionally marginless, allow row content to span from edge to edge

Properties

NameDefaultValueDescription
fixed{ left or center }Grid is fixed width and aligned as specified for viewports larger than 1599px
marginlessfalseBooleanGrid has no margin, row content can span edge to edge
tagNamedivThe type of tag to use when rendering this element
classNameThe CSS class name of this element

Row

Container for Col components, implemented with flexbox

Features

  • Reverse the flow direction of contained Col components
  • Horizontal alignment based on flow direction, start, center, or end
  • Vertically align contained Col components, top, middle, bottom
  • Evenly distribute unconsumed space around or between contained Col components

Properties

NameDefaultValueDescription
reversefalseBooleanReverse direction of this row
startArray of sizesJustify content to the start for the specified sizes (based on direction)
centerArray of sizesCenter content within this row for the specified sizes
endArray of sizesJustify content to the end for the specified sizes (based on direction)
topArray of sizesVertically align content to top for the specified sizes
middleArray of sizesVertically align content to middle for the specified sizes
bottomArray of sizesVertically align content to bottom for the specified sizes
aroundArray of sizesEvenly distribute unused space around columns for the specified sizes
betweenArray of sizesEvenly distribute unused space between columns for the specified sizes
tagNamedivThe type of tag to use when rendering this element
classNameThe CSS class name of this element

Col

Responsively sized, positioned, and visible component contained by a Row

Features

  • Responsive width expressed as columns consumed
  • Offset expressed as columns skipped before consuming columns
  • Responsively hide for any configuration of screen sizes
  • Force to beginning or end of Row

Properties

NameDefaultValueDescription
xs4Integer, 1-4Number of columns to consume on extra-small (4 column) viewports
xs8Integer, 1-8Number of columns to consume on extra-small (8 column) viewports
sm8Integer, 1-8Number of columns to consume on small (8 column) viewports
sm12Integer, 1-12Number of columns to consume on small (12 column) viewports
smInteger, 1-12Shorthand for sm12
md12Integer, 1-12Number of columns to consume on medium (12 column) viewports
mdInteger, 1-12Shorthand for md12
lg12Integer, 1-12Number of columns to consume on large (12 column) viewports
lgInteger, 1-12Shorthand for lg12
xl12Integer, 1-12Number of columns to consume on extra-large (12 column) viewports
xlInteger, 1-12Shorthand for xl12
xs4OffsetInteger, 0-3Number of columns to offset on extra-small (4 column) viewports
xs8OffsetInteger, 0-7Number of columns to offset on extra-small (8 column) viewports
sm8OffsetInteger, 0-7Number of columns to offset on small (8 column) viewports
sm12OffsetInteger, 0-11Number of columns to offset on small (12 column) viewports
smOffsetInteger, 0-11Shorthand for sm12Offset
md12OffsetInteger, 0-11Number of columns to offset on medium (12 column) viewports
mdOffsetInteger, 0-11Shorthand for md12Offset
lg12OffsetInteger, 0-11Number of columns to offset on large (12 column) viewports
lgOffsetInteger, 0-11Shorthand for lg12Offset
xl12OffsetInteger, 0-11Number of columns to offset on extra-large (12 column) viewports
xlOffsetInteger, 0-11Shorthand for xl12Offset
firstArray of sizesPresent this column first for the specified sizes (based on row direction)
lastArray of sizesPresent this column last for the specified sizes (based on row direction)
hiddenOnlyArray of sizesHide this column for the specified sizes
hiddenDownSizeHide this column for sizes equal to or smaller than the specified size
hiddenUpSizeHide this column for sizes equal to or larger than the specified size
tagNamedivThe type of tag to use when rendering this element
classNameThe CSS class name of this element

Example

import React from 'react';
import { Grid, Row, Col } from 'react-material-responsive-grid';

class App extends React.Component {
  render() {
    return (
      <Grid>
         <Row>
            <Col xs4={4} lg={6}>
               <p>This column consumes the entire row for extra-small,
               small, and medium screens.  For large and extra-large
               screens, it consumes half of the row.</p>
            </Col>
            <Col hiddenDown="md" lg={6}>
               <p>This column isn't visible for extra-small, small, 
               and medium screens, but is visible for large and 
               extra-large screens.  It consumes half of the row.</p>
            </Col>
            <Col hiddenDown="sm" hiddenUp="xl" md={12}>
               <p>This column is only visible for medium and large
               screens and consumes the entire row.</p>
            </Col>
            <Col hidden={['sm8', 'sm', 'lg']} xs4={4}>
               <p>This column is hidden for small and large screens
               and consumes the entire row.</p>
            </Col>
         </Row>
      </Grid>
    );
  }
}

Inspiration