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

BlockSpacer is used to create empty block space, typically when variable spacing is needed between multiple elements.

Note that you should favor BlockStack when spacing between all elements is the same.

Support
Targets (50)

Supported targets


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.


Style is a helper for authoring conditional values for prop styles.

Write complex conditional styles based on one or more conditions, such as viewport sizes and interactive states, in a concise and expressive way.

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.


Basic BlockSpacer

Example

Basic BlockSpacer

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

export default reactExtension(
'purchase.checkout.block.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/checkout';

export default extension('purchase.checkout.block.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);
});

Was this page helpful?