Manage UI extension layout (BETA)
Sales Hub
- Enterprise
Service Hub
- Enterprise
By default, UI extension components will arrange themselves based on their content, order, and any layout-related props included with the component, such as the width
prop for images. But you can further configure your extension's layout using the Flex
and Box
components, which are based on the CSS flexbox layout.
Flex
and Box
are both used as wrappers around other components. Flex
can be used on its own, while Box
can be used as a wrapper around Flex
child-items to fine tune spacing of individual components. Below, learn more about each component along with usage examples.
The Flex
component renders an empty div
container set to display=flex
. When wrapped around other components, this enables those child components to be arranged using props.
Below are the available Flex
props. To review all Flex
prop definitions, check out the components reference guide.
Prop | Values | Description |
---|---|---|
direction |
|
Arranges components horizontally or vertically by setting the main axis. |
justify |
|
Distributes components along the main axis using the available free space. |
align |
|
Distributes components along the cross-axis using the available free space. |
alignSelf |
|
Distributes a child component along the cross-axis using the available free space. Use this prop for nested child |
wrap |
|
Whether components will wrap instead of trying to fit on one line. |
gap |
|
Sets the spacing between components. |
Review the examples below to see how the Flex
component can be used to arrange components in various ways.
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.
To arrange components horizontally and evenly spaced:
To arrange components horizontally, evenly spaced, and with equal spacing on the left and right margins:
To arrange components horizontally at the end of the extension container:
To arrange components horizontally at the center of the extension container:
To arrange components horizontally at the start of the extension container:
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.
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.
To arrange components vertically at the start of the extension container:
To arrange components vertically at the center of the extension container:
To arrange components vertically at the end of the extension container:
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.
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.
When wrapping components with Flex
, you can further configure individual component layout by wrapping a child of Flex
in a Box
component.
This component supports the following props. To review all Box
prop definitions, check out the components reference guide.
Prop | Values | Description |
---|---|---|
alignSelf |
|
Distributes a child component along the cross-axis using the available free space. Use this prop for nested child |
flex |
|
Distributes components based on the available empty space around them. |
Use the flex
prop in a Box
component to assign any extra spacing to components using either a default value (e.g. auto
) or a specific number. When using a number, the components will be distributed based on the ratio of their assigned numbers.
For example, the four tiles below take up an increasing amount of space based on their flex
values.
When using Box
, you only need to wrap components that you want to adjust. For example, if you wrap one component in a Box
with a flex
value, only that one component will have its width adjusted based on the available empty space.
flex
value for only one Box
, you can use any number. This is because any number on its own will result in all available space being assigned to that one component.
You can also use the alignSelf
prop to override alignment rules for individual Box
components.
Thank you for your feedback, it means a lot to us.