Package | react-flex-lite |
Description | Flexbox components for React, as minimal as possible |
$ npm install react-flex-lite --save
Heavily inspired by reflexbox and rebass.
This module aims to provide a very lightweight set of components on top of flexbox CSS and layout, and a higher order component to add this functionality to your own components. It does not handle breakpoints, media query listeners, or any other elements of responsive design. For that functionality, you should combine with a library like react-responsive.
import { Box, Flex } from 'react-flex-lite'
const Example = () => (
<Flex column auto>
<Flex shrink={0}>
<Box>1</Box>
<Box>2</Box>
<Box>3</Box>
</Flex>
<Flex shrink={0}>
<Box>1</Box>
<Box>2</Box>
<Box>3</Box>
</Flex>
</Flex>
)
For code clarity, VBox is a shorthand alias around <Flex column>
and HBox is an alias for <Flex />
import { HBox, VBox } from 'react-flex-lite'
const Example = () => (
<VBox auto>
<Flex shrink={0}>
<Box>1</Box>
<Box>2</Box>
<Box>3</Box>
</HBox>
<HBox shrink={0}>
<Box>1</Box>
<Box>2</Box>
<Box>3</Box>
</HBox>
</VBox>
)
import { Layout } from 'react-flex-lite'
@Layout()
const Example = () => <div>Test</div>
margin
- number (for grid index, or pixels) or string (ie "100%")margin-bottom
- number (for grid index, or pixels) or string (ie "100%")margin-top
- number (for grid index, or pixels) or string (ie "100%")margin-right
- number (for grid index, or pixels) or string (ie "100%")margin-left
- number (for grid index, or pixels) or string (ie "100%")margin-right
and margin-left
- number (for grid index, or pixels) or string (ie "100%")margin-top
and margin-bottom
- number (for grid index, or pixels) or string (ie "100%")padding
- number (for grid index, or pixels) or string (ie "100%")padding-bottom
- number (for grid index, or pixels) or string (ie "100%")padding-top
- number (for grid index, or pixels) or string (ie "100%")padding-righht
- number (for grid index, or pixels) or string (ie "100%")padding-left
- number (for grid index, or pixels) or string (ie "100%")padding-right
and padding-left
- number (for grid index, or pixels) or string (ie "100%")padding-top
and padding-bottom
- number (for grid index, or pixels) or string (ie "100%")height
- number (for pixels) or string (ie "100%")width
- number (for pixels) or string (ie "100%")display: flex
- booleaninline-flex
- booleanflex-wrap
- booleanrow-reverse
- booleanflex-direction: column
- booleanalign-items
- One of 'normal', 'flex-start', 'flex-end', 'center', 'start', 'end', 'self-start', 'self-end', 'baseline', 'stretch', 'initial', 'inherit'align-content
- 'start', 'end', 'flex-start', 'flex-end', 'center', 'normal', 'baseline', 'space-between', 'space-around', 'space-evenly', 'stretch', 'initial', 'inherit'align-self
- One of 'auto', 'normal', 'self-start', 'self-end', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline', 'initial', 'inherit'justify-content
- One of 'start', 'end', 'flex-start', 'flex-end', 'center', 'left', 'right', 'normal', 'space-between', 'space-around', 'space-evenly', 'baseline', 'initial', 'inherit'order
- numberflex-shrink
- number, or boolean for 0 or 1flex-grow
- number, or boolean for 0 or 1flex-basis
- numberflex: 1 1 auto
when trueBy default, this library comes with an 8px grid configuration:
{
"space": [0, 8, 16, 32, 64]
}
To provide your own configuration, you can provide it via context:
import { LayoutContext } from 'react-flex-lite'
const config = {
space: [0, 10, 20, 30, 40]
}
// in the root of your app
<LayoutContext.Provider value={config}>
<YourApplication />
</LayoutContext.Provider>
Generated using TypeDoc