2.5.1 • Published 1 year ago

react-flexybox v2.5.1

Weekly downloads
4
License
MIT
Repository
github
Last release
1 year ago

React Flexy Box

React flexy box is a simple to use flexbox system for your React project based on the original flexybox library

If you've used the bootstrap layout system, then react-flexybox should be relatively familiar.

  • Straight forward and familiar API for controlling your layout
  • built with styled-components - no css/scss means no need to add special loaders/config
  • based off actual uses cases in production apps

Live Demo

https://react-flexybox-demo.netlify.com/

Browser Support

"Chrome >= 48",
"Firefox >= 44",
"Firefox ESR",
"Safari >= 9.1",
"Edge >= 12",
"ios_saf >= 9.3",
"ie 11"

Installation

dependencies: react 15+, styled-components 3+

npm install react-flexybox styled-components

or

yarn add react-flexy-box styled-components

API

<Container />

Optional wrapper

proptypevaluesdefaultdescription
fluidbooleanfalsetrue: sets content to 100% of page width | false: sets a max-width for content
classNamestringset the className on the Container Element
styleobjectset the style on the Container Element
componentfunction | stringdivThe component to render the Container as

<Row>

Row wraps Cols

proptypevaluesdefaultdescription
gutternumber0
columnDivisioninteger12allows columns divisions to be overidden (i.e. 24 = smaller columns than 12)
minColWidthsnumberoverride the minWidth for all Cols within the Row
wrapstringnowrap \| wrap \| wrap-reversewrapwhether flex items should wrap when the window is resized
directionstringrow \| row-reverse \| column \| column-reverserow
justifyContentstringflex-start \| flex-end \| center \| space-between \| space-around \| space-evenlyflex-startjustityContent aligns the items inside a flex container along the x axis
alignContentstringflex-start \| flex-end \| center \| baseline \| stretchstretchalignContent aligns the whole structure according to its value and has no effect when items are in a single line
alignItemsstringflex-start \| flex-end \| center \| space-between \| space-around \| stretch \| baselinestretchalignItems aligns the items inside a flex container along the y axis just like justifyContent does along the x axis
classNamestringset the className on the Row Element
styleobjectset the style on the Row Element
debugbooleanfalseadds bounding boxes to help debug layout issues
heightstringallows setting the Row height e.g. height="100px"
componentfunction | stringdivThe component to render the Row as
centerbooleanfalseshortcut to center child Col items horizontally and vertically
fillbooleanfalseshortcut that sets Row to height: 100% - (overrides 'height')
paddingstring0sets padding on Row
paddingTopstring0sets padding-top on Row
paddingLeftstring0sets padding-left on Row
paddingBottomstring0sets padding-bottom Row
paddingRightstring0sets padding-right on Row
  • <Row gutter={4} minColWidth={100}> sets child Col flex items to margin of 4px and all min-widths to 100px within Row
  • <Row justifyContext="center"> center justifies child Col flex items horizontally within the Row
  • <Row justifyContext="center" alignItems="center" > center justifies child Col flex items horizontally and vertically within the Row

<Col>

Flex Items

proptypevaluesdefaultdescription
orderinteger0set the order of flex items
alignSelfstringauto \| flex-start \| flex-end \| center \| baseline \| stretchautocenter the alignments for one of the items inside a flexible element
flexboolean | numberfalse \| 1-12sets the default flex size
xsnumber1-120 - 599px
smnumber1-12600 - 959px
mdnumber1-12960px - 1280px
lgnumber1-121280px or greater
classNamestringset the className on the Col Element
styleobjectset the style on the Col Element
componentfunction | stringdivThe component to render the Col as
  • <Col flex={6}> sets the default flex size
  • <Col flex> sets the item to auto stretch
  • <Col flex={6} xs={12}> xs (xs, sm, md, or lg) used togther with flex - you can easily set a default flex size for any size other than the xs breakpoint
  • <Col flex={6} order={2}> ... <Col flex={6} order={1}> The last Col will be ordered as first
  • values for flex ranges are dependent on columnDivisions

Basic Usage

import { Container, Row, Col } from 'react-flexybox';

UMD Usage

...
<head>
  <link rel="stylesheet" href="https://react-flexybox.netlify.com/react-flexybox.min.js">
</head>
...

// ES6
const {
  Container,
  Row,
  Col,
} = ReactFlexyBox;

//ES Old School
var Container = ReactFlexyBox.Container;
var Row = ReactFlexyBox.Row;
var Col = ReactFlexyBox.Col;

Supported Browsers

react-flexybox is supports on browsers that support flex. It will be up to you to set your autoprefixing appropriatly especially if you use IE 11

Supported Browsers

Contributing

  • npm install yarn jest -g
  • yarn build-all to generate dist
  • yarn build-demo to generate/update demo

Scripts

  • yarn build - produces production version of your library under the dist folder
  • yarn build-all - produces production & dev version of your library under the dist folder
  • yarn dev - produces development version of react-flexybox and runs a watcher
  • yarn test - runs the tests
  • yarn test:watch - same as above but in a watch mode
  • yarn demo:build - builds the demo

Built with react-flexybox

Inspiration

2.5.1

1 year ago

2.5.0

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.0

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.0

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago