Flexbox
FlexBox is available in React Visage only. It is a simple, unstyled container that understands CSS flex layout without the need for adding any custom CSS.
Playground
Usage
To get familiar with the intricacies of flex
layout, check out A Complete Guide to Flexbox
Our FlexBox
component understands only a subset of the possible options for flex
layouts, but it should cover most use-cases.
justifyContent
- aligns items along the primary axis (x-axis by default)alignItems
- aligns items along the secondary axis (y-axis by default)flexWrap
- determines whether the items in theFlexBox
should wrap to the next line or notflexDirection
- determines whether the items in theFlexBox
are laid out in a row or column, this also switches the primary and secondary axes!
Note that the border below is only for illustrative purposes. This is just a div (or whatever element you want via the as
prop).
<FlexBox justifyContent="center" alignItems="center">these contents will be center-aligned on both axes</FlexBox>
Components
FlexBox
Prop | Type | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
flexWrap | "inherit" | "initial" | "wrap" | "-moz-initial" | "revert" | "unset" | "nowrap" | "wrap-reverse" | The Syntax: Initial value:
| ||||||||||||||||||||||||||
flexDirection | "row" | "inherit" | "initial" | "-moz-initial" | "revert" | "unset" | "column" | "column-reverse" | "row-reverse" | The Syntax: Initial value:
| ||||||||||||||||||||||||||
alignItems | AlignItems | The CSS Syntax: Initial value: Supported in Flex Layout
Supported in Grid Layout
@see https ://developer.mozilla.org/docs/Web/CSS/align-items | ||||||||||||||||||||||||||
justifyContent | JustifyContent | The CSS Syntax: Initial value: Supported in Flex Layout
Supported in Grid Layout
@see https ://developer.mozilla.org/docs/Web/CSS/justify-content |
All other props are forwarded to the element specified in thecomponent
prop(default: <div/>
)