Learn about the Spacer component for use in UI extensions.
Use the Spacer component to add vertical space between components. This component is intended for one-off use in situations where other layout components like Flex don’t fully provide the spacing you need. You can use this component in tandem with the AutoGrid, Flex, Box, and Inline components to manage extension layout.
For consistent spacing between multiple components, use the Flex component with the direction="column" and the gap props instead. Flex automatically applies uniform spacing between children, which makes layout easier to maintain.
import { Button, Spacer, Text } from '@hubspot/ui-extensions';hubspot.extend(() => <Extension />);const Extension = () => { return ( <> <Text>These buttons have medium spacing between them:</Text> <Button>Button</Button> <Spacer size="medium" /> <Button>Button</Button> </> );};
Props
Prop
Type
Description
Distances
The size prop controls how much vertical space is rendered. Each size maps to a consistent spacing value from the HubSpot design system:
extra-small / xs: minimal spacing for tightly grouped elements.
small / sm: default spacing suitable for most use cases.
medium / md: moderate spacing for separating related content sections.
large / lg: generous spacing for creating clear visual breaks.
extra-large / xl: maximum spacing for major section divisions.
Spacer vs. Flex
For most layouts, you should use Flex with direction="column" and a gap value instead of Spacer, as it provides uniform spacing between all children without needing to manually insert Spacer components.