FlexBox
import { FlexBox, FlexRow, FlexCol } from 'cx/widgets';FlexBox is a convenience widget for setting up simple flex-box based layouts. FlexBox provides
a number of shortcut options which make it easy to justify, align or add spacing to the content.
<FlexRow spacing target="desktop">
<div style="flex: 1; height: 30px; background: lightgray;" />
<div style="flex: 1; height: 30px; background: lightgray;" />
<div style="flex: 1; height: 30px; background: lightgray;" />
</FlexRow>
<FlexRow spacing target="tablet">
<div style="flex: 1; height: 30px; background: lightgray;" />
<div style="flex: 1; height: 30px; background: lightgray;" />
</FlexRow>target="desktop"
This will break into multiple rows on screens smaller than desktop, e.g. tablets and phones.
target="tablet"
This will break into multiple rows on phones, but will remain in one line on desktop screens.
Notes
Please note that CSS based layouts should be preferred to FlexBox for more complex arrangements.
spacingoption sets a negative margin which may cause unexpected behaviour in some scenarios.
FlexRow = FlexBox + direction="row"
FlexCol = FlexBox + direction="column"
Configuration
| Property | Description | Type |
|---|---|---|
align | Specifies the alignment of items. One to one mapping to CSS | string |
direction | Flex direction. Default is | string |
hpad | Add horizontal padding to the box. Allowed values are | string/boolean |
hspacing | Add horizontal spacing between items by applying a margin to children. Allowed values are | string/boolean |
justify | Defines how space is distributed between and around flex items.
One to one mapping with CSS | string |
nested | Set to | boolean |
pad | Add padding to the box. Allowed values are | string/boolean |
spacing | Add spacing between items by applying a margin to children. Allowed values are | string/boolean |
target | Indicate target screen size. If screen size is too small, flexbox breaks and each item takes a full row.
Supported values are | string |
vpad | Add vertical padding to the box. Allowed values are | string/boolean |
vspacing | Add vertical spacing between items by applying a margin to children. Allowed values are | string/boolean |
wrap | Set to | boolean |
baseClass | Base CSS class. Default is | string |
items | List of child elements. | array |
layout | Define an inner layout. | string/object |
mod | Appearance modifier. For example, | string/array |
outerLayout | Defines the outer layout which wraps the widget. | widget |
plainText | Set to | boolean |
preserveWhitespace | Keep whitespace in text based children. Default is | boolean |
putInto | Used with outer layouts. Specifies the name of the content placeholder which should render the widget. | string |
trimWhitespace | Remove all whitespace in text based children. Default is | boolean |
vdomKey | Key that will be used as the key when rendering the React component. | string |
visible | Visibility of the widget. Defaults to | boolean |