
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
Flexbox, done the React way.
import {
FlexContainer,
FlexItem
} from 'flexor';
class App extends PureComponent {
render() {
return (
<FlexContainer>
<FlexItem sizeTo="content">
I will be sized to my content, and no larger
</FlexItem>
<FlexItem>
I will grow to fit the rest of the container
</FlexItem>
</FlexContainer>
);
}
}
This library provides a declarative and streamlined approach towards building flexbox-based layouts, building on top of existing knowledge while removing the boilerplate. It targets implementation simplicity without sacrificing the full capabilities of flexbox.
There are a number of common usage examples provided in the examples in the dev app.
The container of flexbox items (all possible options are shown, but none are required).
<FlexContainer
alignContent="center"
alignItems="start"
column
columnReverse
direction="row"
element="section"
justifyContent="between"
inline
inlineAlign="top"
row
rowReverse
wrap="wrap"
>
...
</FlexContainer>
string, defaults to "stretch"
The align-items value for the container. Valid values:
around (translates to space-around)between (translates to space-between)centerend (translates to flex-end)start (translates to flex-start)stretchstring, defaults to "stretch"
The align-content value for the container. Valid values:
baselinecenterend (translates to flex-end)start (translates to flex-start)stretchboolean, defaults to false
Is the flex-direction of the container column. Shorthand for direction="column".
boolean, defaults to false
Is the flex-direction of the container column-reverse. Shorthand for direction="column-reverse".
string, defaults to "row"
The flex-direction value for the container. Valid values:
columncolumn-reverserowrow-reverse(function|string), defaults to "div"
The element type to use for the container element. Accepts either string values for standard HTML elements, or function values for React components. This is often used for semantic element usage (header, footer, etc.).
string, defaults to "start"
The justify-content value for the container. Valid values:
around (translates to space-around)between (translates to space-between)centerend (translates to flex-end)start (translates to flex-start)boolean, defaults to false
Sets the flex container to be inline.
string, defaults to "baseline"
When inline is applied, the vertical-align. Valid values:
baselinebottomcentertopboolean, defaults to true
Is the flex-direction of the container row. Shorthand for direction="row".
boolean, defaults to false
Is the flex-direction of the container row-reverse. Shorthand for direction="row-reverse".
(boolean|string), defaults to "nowrap"
If a string, sets the flex-wrap value for the container. Valid values:
nowrapwrapwrap-reverseIf a boolean, applies wrap as the value of flex-wrap.
A child of a flexbox container (all possible options are shown, but none are required).
<FlexItem
alignSelf="center"
basis={200}
element={FlexContainer}
grow={3}
order={-1}
shrink
sizeTo="content"
>
...
</FlexItem>
string, defaults to "auto"
Sets the align-self value for the item. Valid values:
autobaselinecenterend (translates to flex-end)start (translates to flex-start)stretch(number|string) defaults to "auto"
Sets the flex-basis value for the item. If a number, will translate to that exact value in px. If a string, will use the value directly.
(function|string), defaults to "div"
The element type to use for the container element. Accepts either string values for standard HTML elements, or function values for React components. This is often used for semantic element usage (header, footer, etc.).
Tip: Use this in combination with FlexContainer to create flex items that are also flex containers.
<FlexItem element={FlexContainer}>
(boolean|number|string), defaults to 1
Sets the flex-grow value for the item. If a number or a string, will use the value directly (must be an integer between 0 and 9). If a boolean, will set the value to be 1 to trigger grow.
(number|string), defaults to 0
Sets the order value for the item (must be an integer between -9 and 9).
(boolean|number|string), defaults to 1
Sets the flex-shrink value for the item. If a number or a string, will use the value directly (must be an integer between 0 and 9). If a boolean, will set the value to be 1 to trigger shrink.
(number|string)
Helper prop, which will set the value passed to flex-basis and also set flex-grow and flex-shrink to 0.
Besides all valid values for basis, the additional value of content can be used, which will set the basis to auto.
<FlexItem sizeTo="content">
The following global options are available:
{
debug: boolean, // defaults to false
fixFlexbugs: boolean, // defaults to true
prefix: Function // defaults to prefixAll from inline-style-prefixer
}
To modify any of the options, you can call the setOptions method with an object of options to apply. They will be shallowly merged into the existing options object, and used for all implementations of flexor components after applied.
setOptions({
debug: true,
fixFlexbugs: false,
prefix: myCustomPrefixer
})
boolean, defaults to false
By default the styles will be added to a style tag using the very fast insertRule API for stylesheets. The drawback with this is that it is difficult to diagnose style declarations, and sourcemaps do not work (as there is no explicit source). By setting debug to true, the styles will instead be appended as textContent to the style tag, so that the styles applied are traceable and can be altered in devtools.
boolean, defaults to true
By default flexor will apply additional CSS values to containers and items in specific situations to work around buggy flexbox implementations on older browsers. If you set this option to false, it will disable these workarounds.
Tip: These workarounds may result in your own CSS getting overridden in very specific scenarios (example: explicitly declaring a min-height on items inside of a column flex container). Making your own CSS more specific by providing a parent selector should suffice.
Function, defaults to prefixAll
By default flexor uses the static prefixAll method provided by inline-style-prefixer, which covers a large majority of modern browser use cases. That said, if you need to support specific legacy browsers such as IE10, you will need to provide a custom prefixer. This method will receive a single parameter, the object of styles, and expects an object of prefixed styles to be returned.
Tip: If you do not want to prefix styles at all, pass an identity function to this option.
If using the built version provided in dist, you will need to include additional libraries as dependencies prior to the inclusion of flexor:
Standard stuff, clone the repo and npm install dependencies. The npm scripts available:
build => run webpack to build development dist file with NODE_ENV=developmentbuild:minifed => run webpack to build production dist file with NODE_ENV=productiondev => run webpack dev server to run example app (playground with examples)dist => runs build and build-minifieddocs => builds the docs via jsdoclint => run ESLint against all files in the src folderprepublish => run lint, test, transpile:es, transpile:lib, disttest => run AVA test functions with NODE_ENV=testtest:coverage => run test but with nyc for coverage checkertest:update => run test, but update all snapshotstest:watch => run test, but with persistent watchertranspile:lib => run babel against all files in src to create files in libtranspile:es => run babel against all files in src to create files in es, preserving ES2015 modules (for pkg.module)FAQs
Flexbox, done the React way.
We found that flexor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.