Skip to main content
Migrate to Polaris

Version 2025-07 is the last API version to support React-based UI components. Later versions use web components, native UI elements with built-in accessibility, better performance, and consistent styling with Shopify's design system. Check out the migration guide to upgrade your extension.

BlockSpacer

The BlockSpacer component creates empty vertical space between elements. Use BlockSpacer to insert variable amounts of block-axis spacing when elements need different gaps, such as adding extra breathing room between major content groups.

BlockSpacer supports predefined spacing values from the design token set for consistent vertical rhythm. When all elements need the same gap, use BlockStack with a spacing prop instead.

Support
Targets (25)

Configure the following properties on the BlockSpacer component.

string

A unique identifier for the component. Use this to target the component in scripts or stylesheets, or to distinguish it from other instances of the same component.

Anchor to spacing
spacing
<>
Default: 'base'

The size of the spacer.

The StyleHelper utility lets you write conditional values for the spacing property based on viewport size or interaction state. Use it to adjust BlockSpacer spacing responsively, such as applying tighter spacing on small screens and looser spacing on larger viewports.

Configure the following style properties.

Anchor to default
default
<T>(defaultValue: T) => <T, >
required

Sets an optional default value to use when no other condition is met.

<T>(conditions: , value: T) => <T, >
required

Adjusts the style based on different conditions. All conditions, expressed as a literal object, must be met for the associated value to be applied.

The when method can be chained together to build more complex styles.


Anchor to Add variable vertical spacingAdd variable vertical spacing

Use BlockSpacer to insert specific amounts of vertical space between elements. This is useful when you need different spacing values in the same layout.

Add variable vertical spacing

A BlockSpacer creating vertical space between elements.

Add variable vertical spacing

import {
reactExtension,
BlockSpacer,
View,
} from '@shopify/ui-extensions-react/customer-account';

export default reactExtension(
'customer-account.page.render',
() => <Extension />,
);

function Extension() {
return (
<>
<View border="base" padding="base">
View
</View>
<BlockSpacer spacing="loose" />
<View border="base" padding="base">
View
</View>
</>
);
}
import {extension, BlockSpacer, View} from '@shopify/ui-extensions/customer-account';

export default extension('customer-account.page.render', (root) => {
const blockSpacer = root.createComponent(View, undefined, [
root.createComponent(View, {border: 'base', padding: 'base'}, 'View'),
root.createComponent(BlockSpacer, {spacing: 'loose'}),
root.createComponent(View, {border: 'base', padding: 'base'}, 'View'),
]);

root.appendChild(blockSpacer);
});

  • Set spacing explicitly: BlockSpacer defaults to base. Always set the spacing prop to make the intended gap size clear and avoid relying on the default.
  • Use StyleHelper for responsive spacing: Wrap the spacing value with Style.default().when() to apply tighter spacing on small viewports and looser spacing on larger ones.
  • Don't stack multiple spacers: Use a single BlockSpacer with a larger spacing value like loose or extraLoose instead of placing multiple spacers in a row.

  • BlockSpacer only creates vertical (block-axis) space. For horizontal spacing, use InlineSpacer.
  • BlockSpacer is an empty element. It can't contain children or display content.
  • Spacing values are limited to the predefined design token set. Custom pixel values aren't supported.

Was this page helpful?