Flex
Quick start
Here's a quick start guide to get started with the flex component
Importing flex
import { Flex } from "@hover-design/react";
Code Snippets and Examples
Flex Default
<Flex>
<div>flex 1</div>
<div>flex 2</div>
</Flex>
flex 1
flex 2
Flex Direction
<Flex flexDirection="column">
<div> flex 1 </div>
<div> flex 2 </div>
</Flex>
column
flex 1flex 2row
flex 1flex 2column-reverse
flex 1flex 2row-reverse
flex 1flex 2
Flex Wrap
<Flex flexWrap="wrap">
<div> flex 1 </div>
<div> flex 2 </div>
</Flex>
wrap
flex 1flex 2flex 3flex 4flex 5flex 6flex 7flex 8nowrap
flex 1flex 2flex 3flex 4flex 5flex 6flex 7flex 8
Align Content
<Flex alignContent="center">
<div> flex 1 </div>
<div> flex 2 </div>
</Flex>
center
flex 1flex 2flex 3flex 4flex 5flex 6flex 7flex 8flex-start
flex 1flex 2flex 3flex 4flex 5flex 6flex 7flex 8flex-end
flex 1flex 2flex 3flex 4flex 5flex 6flex 7flex 8space-between
flex 1flex 2flex 3flex 4flex 5flex 6flex 7flex 8space-around
flex 1flex 2flex 3flex 4flex 5flex 6flex 7flex 8stretch
flex 1flex 2flex 3flex 4flex 5flex 6flex 7flex 8
Justify Content
<Flex justifyContent="center">
<div> flex 1 </div>
<div> flex 2 </div>
</Flex>
center
flex 1flex 2flex 3flex-start
flex 1flex 2flex 3flex-end
flex 1flex 2flex 3space-between
flex 1flex 2flex 3space-around
flex 1flex 2flex 3space-evenly
flex 1flex 2flex 3
Align Items
<Flex alignItems="center">
<div> flex 1 </div>
<div> flex 2 </div>
</Flex>
center
flex 1flex 2flex 3flex 4flex-start
flex 1flex 2flex 3flex 4flex-end
flex 1flex 2flex 3flex 4baseline
flex 1flex 2flex 3flex 4stretch
flex 1flex 2flex 3flex 4
Flex Shrink
<Flex>
<Flex flexShrink="1"> flex 1 </Flex>
<div> flex 2 </div>
<div> flex 3 </div>
</Flex>
flex 1
flex 2
flex 3
Flex Grow
<Flex>
<div> flex 1 </div>
<Flex flexGrow="2"> flex 2 </Flex>
<div> flex 3 </div>
</Flex>
flex 1
flex 2
flex 3
Flex Basis
<Flex>
<div> flex 1 </div>
<div> flex 2 </div>
<Flex flexBasis="120px"> flex 3 </Flex>
</Flex>
flex 1
flex 2
flex 3
Gap
<Flex gap="20px">
<div> flex 2 </div>
<div> flex 3 </div>
</Flex>
flex 1
flex 2
flex 3
Props Referece
Attributes | Values | Optional ? |
---|---|---|
flexDirection | row | column | row-reverse | column-reverse | Yes |
flexWrap | wrap | no-wrap | Yes |
alignContent | normal | start | center | end | flex-start | flex-end | space-between | space-around | space-evenly | stretch | Yes |
justifyContent | normal | start | center | end | flex-start | flex-end | space-between | space-around | stretch | Yes |
alignItems | normal | start | center | flex-start | flex-end | space-between | space-around | stretch | end | Yes |
flexShrink | number | Yes |
flexGrow | number | Yes |
flexBasis | width | max-content | min-content | fit-content | content | Yes |
gap | normal | length | percentage | Yes |
onClick | () => void; | Yes |
onHover | () => void; | Yes |
display | flex | inline-flex | Yes |