ffx
Teeny-tiny flexbox grid for React. 2kb gzipped.

Features/Goals
- No boilerplate, no config
- Outputs Real CSS™
- Nestable
- Uses relative units (em)
- SSR API
Usage
ffx exports two components, Flex and Box. Flex is designed to be the wrapper and immediate parent of Box.
import { Flex, Box } from 'ffx'
<Flex>
<Box />
<Box />
</Flex>
Examples:
<Flex gutter={1} />
<Flex gutter={[ 1, [ 800, 2 ] ]} />
<Flex wrap={true} />
<Flex wrap={[ true, [ 800, false ] ]} />
<Flex alignItems='flex-start' />
<Flex justifyContent='flex-start' />
<Box width={1/2} />
<Box width={[ 1, [ 800, 1/2 ] ]} />
<Box width='200px' />
<Box width='auto' />
<Box width={[ '200px', [ 800, 'auto' ] ]} />
<Box order={-1} />
<Box order={[ -1, [ 800, 'unset' ] ]} />
<Box offset={1/4} width={1/2} />
<Box offset={[[800, 1/2]]} width={[ 1, [ 800, 1/2 ] ]} />
CSS output from above elements:
.⚡︎0{margin-left: -0.5em; margin-right: -0.5em}.⚡︎1{flex-wrap: nowrap}.⚡︎3{margin-left: -0em; margin-right: -0em}.⚡︎4{flex-wrap: wrap}@media(min-width:50em){.⚡︎5{flex-wrap: nowrap}}@media(min-width:50em){.⚡︎2{margin-left: -1em; margin-right: -1em}}
Nesting
Grids are fully nestable.
<Flex gutter={1}>
<Box width={1/3} />
<Box width={2/3}>
<Flex gutter={1}>
<Box width={1/2} />
<Box width={1/2} />
</Flex>
</Box>
</Flex>
SSR
This isn't production code, just a simplified example.
import { getCSS } from 'ffx'
const html = renderToString(<App />)
const css = getCSS()
res.send(`
<!DOCTYPE html>
<html>
<head>
<style id="ffx">${css}</style>
</head>
<body>${html}</body>
</html>
`)
MIT License