0.0.5 • Published 6 years ago

aiws-react-flexbox v0.0.5

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
6 years ago

CircleCI npm version

react-flexbox

React flexbox layout with intuitive style settings. There is no fancy compares to other libraries, it is just another way of declaring flexbox layout in react.

Usage

npm install -save aiws-react-flexbox
import {Flex, Box} from 'aiws-react-flexbox';

...
    <Flex
        justify="center"
        align="center"
        p={1}
    >
        <Box
            pl={1}
            pr={1}
            auto
        />
            Left
        </Box>
        <Box
            ml={1}
        >
            Right
        </Box>
    </Flex>
...

API

Flex

PropertyCorresponding CSSValueMeaning
columnflex-direction: column/rowtrue or falselayout content in column or row
reverseflex-direction: row-reverse/column-reversetrue or falselayout content in reverse order
wrapflex-wrapno-wrap or wrap or wrap-reverserender items in one line or multiple lines or multiple lines with reversed order
justifyjustify-contentflex-start or flex-end or center or space-between or space-aroundSpecify how the items are aligned in the main axis
alignalign-itemsflex-start or flex-end or center or space-between or space-aroundSpecify how the items are aligned in the secondary axis
fullWidthwidth: 100%true or falsetake the width of the parent
inlinedisplay: inline-flex
colwidth: (col * 100 / 12)%1..12
autoflex: 1 1 autotrue or falsetake all available space of the parent

Box

PropertyCorresponding CSSValueMeaning
orderordernumbercontrols the order in which they appear in the flex container
autoflex: 1 1 autotrue or falsetake all available space of the parent
growflex-grow:number
shrinkflex-shrink:number
basisflex-basis:string or number
alignalign-self:auto or flex-start or flex-end or center or baseline or stretch

Margin & Padding (same for both)

PropertyCorresponding CSSExample
m={x}margin: (x * 8)pxm={1} means margin: 8px
p={x}padding: (x * 8)pxp={1} means padding: 8px
ml, mr, mt, mbmargin-left, margin-right, margin-top, margin-bottomml={1} means margin-left: 8px
pl, pr, pt, pbpadding-left, padding-right, padding-top, padding-bottompt={1} means padding-top: 8px

Overriden

PropertyExample
stylestyle={margin: 4} means final style will have margin with 4px regardless other settings

Run example locally

npm install
npm run serve

then navigate to http://localhost:8080

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago