react-gridit
React grid using CSS Grid and styled-components
Install
npm i react-gridit
or
yarn add react-gridit
Examples
or checkout the examples React app.
You can run the examples locally by doing npm run examples
.
Rows
<GridRows ="20px"> <Block ="1fr">1</Block> <Block ="2fr">2</Block> <Block ="3fr">3</Block> <Block ="4fr">4</Block> <Block ="5fr">5</Block></GridRows>
Output:
Columns
<GridColumns ="50px"> <Block ="1fr">1</Block> <Block ="2fr">2</Block> <Block ="3fr">3</Block> <Block ="4fr">4</Block> <Block ="5fr">5</Block></GridColumns>
Nesting
<GridRows ="20px"> <GridColumns> <Block ="1fr">1</Block> <Block ="3fr">3</Block> </GridColumns> <GridColumns> <Block ="1fr">1</Block> </GridColumns> <GridColumns> <Block ="1fr">1</Block> <Block ="4fr">4</Block> <Block ="2fr">2</Block> </GridColumns></GridRows>
Areas
<GridArea => <Block >Header</Block> <Block >Sidebar</Block> <Block >Main1</Block> <Block >Main2</Block> <Block >Footer</Block></GridArea>
Output:
Responsive areas
<GridArea = ="(max-width: 599px)" => <Block >A</Block> <Block >B</Block> <Block >C</Block> <Block >D</Block></GridArea>
Output (match):
Output (no match):
License
MIT