A utility component for creating flex containers.

Importing

The component can be imported via:

import { Flex } from '@customerio/pluma-components/react';
<Flex gap="200">
  <Box backgroundColor="information" p="200" />
  <Box backgroundColor="information" p="200" />
  <Box backgroundColor="information" p="200" />
</Flex>

Usage

The PlumaFlex component is a wrapper around Box for making it easier to create flex containers.

Flex direction

The flex direction can be controlled with the direction prop:

<Flex gap="200" direction="column">
  <Box backgroundColor="information" p="200" />
  <Box backgroundColor="information" p="200" />
  <Box backgroundColor="information" p="200" />
</Flex>

Gap

The gap between items can be controlled with the gap prop, which accepts space token values. rowGap and columnGap are also available for more fine-grained control of the gaps.

<Flex gap="400">
  <Box backgroundColor="information" p="200" />
  <Box backgroundColor="information" p="200" />
  <Box backgroundColor="information" p="200" />
</Flex>

Alignment

Main and cross axis alignment can be controlled with justifyContent and alignItems. For example:

<Flex gap="200" style={{ height: '100px' }} alignItems="stretch">
  <Flex 
    alignItems="start" 
    gap="200" 
    backgroundColor="information-minimal"
  >
    <Box backgroundColor="information" p="200" />
    <Box backgroundColor="information" p="200" />
    <Box backgroundColor="information" p="200" />
  </Flex>

  <Flex 
    alignItems="center" 
    gap="200" 
    backgroundColor="information-minimal"
  >
    <Box backgroundColor="information" p="200" />
    <Box backgroundColor="information" p="200" />
    <Box backgroundColor="information" p="200" />
  </Flex>

  <Flex 
    alignItems="end" 
    gap="200" 
    backgroundColor="information-minimal"
  >
    <Box backgroundColor="information" p="200" />
    <Box backgroundColor="information" p="200" />
    <Box backgroundColor="information" p="200" />
  </Flex>

  <Flex 
    alignItems="stretch" 
    gap="200" 
    backgroundColor="information-minimal"
  >
    <Box backgroundColor="information" p="200" />
    <Box backgroundColor="information" p="200" />
    <Box backgroundColor="information" p="200" />
  </Flex>
</Flex>

Wrap

The flex container can be set to wrap with the wrap prop. It accepts a boolean value, or a wrap or nowrap string;

<Flex gap="200" wrap={true}>
  {[...Array(10)].map((_, index) => (
    <Box backgroundColor="information" p="200" />
  ))}
</Flex>

API

PlumaFlex extends Box

Default:row

The direction of the flex container. MDN Flex Direction

Default:false

Whether flex items should wrap over multiple lines. MDN Flex Wrap

On this page