Skip to main content

The Flex component renders an empty div container set to display=flex. When wrapped around other components, it enables those child components to be arranged using props. Flex can contain other Flex or Box components.

To see an example of how Flex and Box can be used for layout, check out HubSpot's Manage layouts: Flex and Box sample project.

ui-extension-components-flex-child

PropTypeDescription
direction'row' (default) | 'column'Arranges the components horizontally or vertically by setting the main axis.
justify'start' (default) | 'center' | 'end' | 'around' | 'between'Distributes components along the main axis using the available free space.
align'start' | 'center' | 'end' | 'baseline' | 'stretch' (default)Distributes components along the cross-axis using the available free space.
alignSelf'start' | 'center' | 'end' | 'baseline' | 'stretch'Distributes a child component along the cross-axis using the available free space. Use this prop for nested Flex and Box components to align them differently from other child components in the Flex group.
wrap'wrap' | 'nowrap' (default)Whether components will wrap rather than trying to fit on one line.
gap'flush' (default) | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large'Sets the spacing between components.

To arrange components horizontally, set direction to row. Then, use justify to configure the horizontal distribution. By default, components will stretch across the container if justify is not specified.

flex-tiles-justify-between
justify={'between'}

flex-tiles-justify-around

justify={'around'}

ui-extensions-layout-tile-justify-start

justify={'start'}

ui-extensions-layout-tile-justify-center

justify={'center'}

ui-extensions-layout-tile-justify-end

justify={'end'}

By default, components in a row will be arranged on one line when possible. Use the wrap prop to wrap components onto new lines when needed.

ui-extensions-layout-tile-row-wrap

To arrange components vertically, set direction to column, then use the align prop to distribute them. By default, components will stretch across the extension container width when align is not specified.

ui-extensions-layout-tile-column-align-start
align={'start'}

ui-extensions-layout-tile-column-align-center

align={'center'}

ui-extensions-layout-tile-column-align-end

align={'end'}

In the Flex component, you can use the gap prop to apply even spacing between the tiles. This prop will apply spacing equally for both row and column directions.

flex-tiles-gap

You can wrap child Flex components with Flex to set more specific rules for individual components. A child Flex component will not inherit props specified in the parent Flex component, so you'll need to repeat any props you've previously defined to maintain them.

ui-extension-components-flex-child