1.0.0 • Published 1 year ago

@element-public/react-grid v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Grid

Description

The Element Design responsive layout grid adapts to screen size and orientation, ensuring consistency across layouts.

See live demos on storybook

Storybook Grid Demos

Install bundle from npm-e

npm i @element-public/react-components @element-public/themes

Optional: install the component individually

npm i @element-public/react-grid @element-public/themes

Open ~/.npmrc in an editor and add the following line to enable the @element-public scope:

@element-public:registry=https://npm.platforms.engineering

Troubleshooting

See below if you have never installed a package from Bayer's npm-enterprise or run into the following error:

npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR!     npm login

Setup an access token

See the devtools npm-e guide to learn how to create an access token if this is the first time you are using a npm-e package at Bayer or you do not have a line that starts with the following in your ~/.npmrc file:

//npm.platforms.engineering/:_authToken=

Notes

Different variations of Grid exist for different use cases. Variations include Grid with Column Spacing, Grid with Custom Ordered Columns, and a Full Height Grid. In general, Grid is an effective tool for organizing content in specifically styled or labeled columns to improve a user's experience.

Breakpoints

RangeColumnsGutterStandard MarginAiry MarginDeviceViewports
0-5994161616Mobile320,260,414
600-7198161632Tablet600
720-8398242432Tablet768,800
840-102312242448Desktop960
1024-143912242464Desktop1024,1280
1440+12242480Desktop1440,1600

Grid Props

NameTypeDefaultRequiredDescription
classNamestringundefinedfalseThe css class name to be passed through to the component markup.
columnGapstring|number'16px'falseSets the column gap for the grid.
fullHeightbooleannullfalseApplies 100% height to the grid and direct children rows. Useful when creating a page layout. Be aware all direct children rows will have a 100% height.
fullWidthbooleannullfalseApplies 100% width to the grid and direct children rows. Useful to maintain full width in a flex container.
gridAlignstring'center'falseAlignment of entire grid: left and right.Accepted Values: center, left, right
rowGapstring|number'16px'falseSets the row gap for the grid.
styleobjectundefinedfalseStyles for the grid.
useMaxWidthbooleanfalsefalseIf true the grid will have a max width according to your theme's breakpoints.
variantstring'standard'falseSelect airy or standard padding.Accepted Values: standard, airy, none

Grid Deprecated Props

NameTypeDefaultRequiredDeprecatedDescription
airybooleanundefinedfalseUse variant='airy' instead.Applies extra padding to each column.

Grid Render Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodenulltrueAccepts GridCol or GridRow.

Grid Col Props

NameTypeDefaultRequiredDescription
alignstringundefinedfalseAlignment of cell within the row: top, middle, bottom. If omitted the col will stretch to the height of the row.Accepted Values: top, middle, bottom
classNamestringundefinedfalseThe css class name to be passed through to the component markup.
desktopColnumbernullfalseSpecifies the number of columns the cell spans.
gridColStartstring|numbernullfalseSpecifies a grid item's start position within the grid column by contributing a line, a span, or nothing (automatic) to its grid placement. Set to any valid grid-column-start.
horizontalAlignstring'left'falseHorizontal alignment of the cell contents of cell content: top, middle, bottom.Accepted Values: left, center, right
ordernumbernullfalseSpecifies the order of the cell.
phoneColnumbernullfalseSpecifies the number of columns the cell spans on a phone.
tabletColnumbernullfalseSpecifies the number of columns the cell spans on a tablet.
verticalAlignstring'top'falseVertical alignment of cell content: top, middle, bottom.Accepted Values: top, middle, bottom

Grid Col Render Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodenullfalseContent to be rendered inside the GridCol. Accepts any valid markup.

Grid Row Props

NameTypeDefaultRequiredDescription
classNamestringundefinedfalseThe css class name to be passed through to the component markup.

Grid Row Render Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodenulltrueContent to be rendered inside the GridRow. Accepts any valid markup.