Features
- Control the space between children.
- Control the alignment of children.
- Control the orientation of children.
Adheres to our spacing tokens.
Basic usage
First, import the component.
import {Flex} from '@pleo-io/telescope'Then use it, like so:
<Flex gap={24} flexWrap="wrap" css={{width: '235px'}}>
<Placeholder width={40} />
<Placeholder width={40} />
<Placeholder width={40} />
<Placeholder width={40} />
<Placeholder width={40} />
<Placeholder width={40} />
</Flex>API reference
The component accepts the following props.
| Prop | Type | Default |
|---|---|---|
columnGapThe space between each column. Default 0. | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
gapThe space between each item. Default 0. Shorthand for | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
mMargin on top, left, bottom and right | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
marginMargin on top, left, bottom and right | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
marginBottomMargin on bottom | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
marginLeftMargin on left | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
marginRightMargin on right | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
marginTopMargin on top | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
marginXMargin on left and right | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
marginYMargin on top and bottom | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
mbMargin on bottom | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
mlMargin on left | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
mrMargin on right | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
mtMargin on top | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
mxMargin on left and right | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
myMargin on top and bottom | enum0, "auto", 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
pPadding on top, left, bottom and right | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
paddingPadding on top, left, bottom and right | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
paddingBottomPadding on bottom | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
paddingLeftPadding on left | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
paddingRightPadding on right | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
paddingTopPadding on top | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
paddingXPadding on left and right | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
paddingYPadding on top and bottom | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
pbPadding on bottom | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
plPadding on left | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
prPadding on right | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
ptPadding on top | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
pxPadding on left and right | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
pyPadding on top and bottom | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 | |
rowGapThe space between each row. Default 0. | enum0, 2, 4, 16, 20, 24, 48, 40, 8, 12, 6, 10, 32, 14, 18, 28, 36, 44, 52, 56, 60 |
| Prop | Type | Default |
|---|---|---|
alignContentThe CSS align-content property sets how the browser distributes space between and around content items along the cross-axis of a flexbox container, and the main-axis of a grid container. | enumnull, "center", "end", "baseline", "start", "space-around", "space-between", "space-evenly", "stretch", "flex-end", "flex-start", "normal", (AlignContent | null)[], { [x: string]: AlignContent | undefined; [x: number]: AlignContent | undefined; }, Any other valid CSS value | |
alignItemsThe CSS align-items property sets the align-self value on all direct children as a group. The align-self property sets the alignment of an item within its containing block. In Flexbox it controls the alignment of items on the Cross Axis, in Grid Layout it controls the alignment of items on the Block Axis within their grid area. | enumnull, "center", "end", "baseline", "start", "stretch", "flex-end", "flex-start", "normal", "self-end", "self-start", "anchor-center", (AlignItems | null)[], { [x: string]: AlignItems | undefined; [x: number]: AlignItems | undefined; }, Any other valid CSS value | |
alignSelfThe align-self CSS property aligns flex items of the current flex line overriding the align-items value. If any of the item's cross-axis margin is set to auto, then align-self is ignored. In Grid layout align-self aligns the item inside the grid area. | enumnull, "center", "auto", "end", "baseline", "start", "stretch", "flex-end", "flex-start", "normal", "self-end", "self-start", "anchor-center", (AlignSelf | null)[], { [x: string]: AlignSelf | undefined; [x: number]: AlignSelf | undefined; }, Any other valid CSS value | |
flexThe flex CSS property specifies how a flex item will grow or shrink so as to fit the space available in its flex container. This is a shorthand property that sets flex-grow, flex-shrink, and flex-basis. | enumnull, string, number, number & {}, (Flex<TLengthStyledSystem> | null)[], { [x: string]: Flex<TLengthStyledSystem> | undefined; [x: number]: Flex<TLengthStyledSystem> | undefined; }, Any other valid CSS value | |
flexBasisNo description available | enumnull, string, number, (FlexBasis<TLengthStyledSystem> | null)[], { [x: string]: FlexBasis<TLengthStyledSystem> | undefined; [x: number]: FlexBasis<TLengthStyledSystem> | undefined; }, Any other valid CSS value | |
flexDirectionThe flex-direction CSS property specifies how flex items are placed in the flex container defining the main axis and the direction (normal or reversed). | enumnull, "inherit", "row", "-moz-initial", "initial", "revert", "revert-layer", "unset", "column", "column-reverse", "row-reverse", (FlexDirection | null)[], { [x: string]: FlexDirection | undefined; [x: number]: FlexDirection | undefined; } | |
flexGrowThe flex-grow CSS property sets the flex grow factor of a flex item main size. It specifies how much of the remaining space in the flex container should be assigned to the item (the flex grow factor). | enumnull, number & {}, (FlexGrow | null)[], { [x: string]: FlexGrow | undefined; [x: number]: FlexGrow | undefined; }, Any other valid CSS value | |
flexShrinkThe flex-shrink CSS property sets the flex shrink factor of a flex item. If the size of all flex items is larger than the flex container, items shrink to fit according to flex-shrink. | enumnull, number & {}, (FlexShrink | null)[], { [x: string]: FlexShrink | undefined; [x: number]: FlexShrink | undefined; }, Any other valid CSS value | |
flexWrapThe flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. If wrapping is allowed, it sets the direction that lines are stacked. | enumnull, "inherit", "-moz-initial", "initial", "revert", "revert-layer", "unset", "nowrap", "wrap", "wrap-reverse", (FlexWrap | null)[], { [x: string]: FlexWrap | undefined; [x: number]: FlexWrap | undefined; } | |
justifyContentThe CSS justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container. | enumnull, "center", "left", "end", "start", "right", "space-around", "space-between", "space-evenly", "stretch", "flex-end", "flex-start", "normal", (JustifyContent | null)[], { [x: string]: JustifyContent | undefined; [x: number]: JustifyContent | undefined; }, Any other valid CSS value | |
justifyItemsThe CSS justify-items property defines the default justify-self for all items of the box, giving them all a default way of justifying each box along the appropriate axis. | enumnull, "center", "left", "end", "baseline", "start", "right", "stretch", "flex-end", "flex-start", "normal", "self-end", "self-start", "legacy", "anchor-center", (JustifyItems | null)[], { [x: string]: JustifyItems | undefined; [x: number]: JustifyItems | undefined; }, Any other valid CSS value | |
justifySelfThe CSS justify-self property set the way a box is justified inside its alignment container along the appropriate axis. | enumnull, "center", "auto", "left", "end", "baseline", "start", "right", "stretch", "flex-end", "flex-start", "normal", "self-end", "self-start", "anchor-center", (JustifySelf | null)[], { [x: string]: JustifySelf | undefined; [x: number]: JustifySelf | undefined; }, Any other valid CSS value | |
orderThe order CSS property sets the order to lay out an item in a flex or grid container. Items in a container are sorted by ascending order value and then by their source code order. | enumnull, number & {}, (Order | null)[], { [x: string]: Order | undefined; [x: number]: Order | undefined; }, Any other valid CSS value |
Related components
- Box: A utility component for working with spacing.
- Inline: A utility component for controlling horizontal layouts.
- Stack: A utility component for controlling vertical layouts.