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.
StyleHelper
The StyleHelper utility enables conditional property values based on viewport sizes and interactive states. Use StyleHelper to write responsive styles that adapt layout components to different screen sizes, hover states, and focus states in a concise and expressive way.
StyleHelper works with the following components to create responsive designs without custom CSS:
| BlockLayout | InlineLayout |
| BlockSpacer | InlineSpacer |
| BlockStack | InlineStack |
| Grid | List |
| GridItem | Pressable |
| Image | ScrollView |
| SkeletonImage | View |
Supported targets
- Customer
Account::Kitchen Sink - customer-account.
footer. render-after - customer-account.
order-index. announcement. render - customer-account.
order-index. block. render - customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. action. menu-item. render - customer-account.
order. action. render - customer-account.
order. page. render - customer-account.
page. render - customer-account.
profile. addresses. render-after - customer-account.
profile. announcement. render - customer-account.
profile. block. render - customer-account.
profile. company-details. render-after - customer-account.
profile. company-location-addresses. render-after - customer-account.
profile. company-location-payment. render-after - customer-account.
profile. company-location-staff. render-after - customer-account.
profile. payment. render-after
Supported targets
- Customer
Account::Kitchen Sink - customer-account.
footer. render-after - customer-account.
order-index. announcement. render - customer-account.
order-index. block. render - customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. action. menu-item. render - customer-account.
order. action. render - customer-account.
order. page. render - customer-account.
page. render - customer-account.
profile. addresses. render-after - customer-account.
profile. announcement. render - customer-account.
profile. block. render - customer-account.
profile. company-details. render-after - customer-account.
profile. company-location-addresses. render-after - customer-account.
profile. company-location-payment. render-after - customer-account.
profile. company-location-staff. render-after - customer-account.
profile. payment. render-after
Anchor to PropertiesProperties
Configure the following style properties.
- Anchor to defaultdefaultdefault<T>(defaultValue: T) => StylesConditionalStyle<T, StylesBaseConditions><T>(defaultValue: T) => StylesConditionalStyle<T, StylesBaseConditions>requiredrequired
Sets an optional default value to use when no other condition is met.
- Anchor to whenwhenwhen<T>(conditions: StylesConditions, value: T) => StylesConditionalStyle<T, StylesBaseConditions><T>(conditions: StylesConditions, value: T) => StylesConditionalStyle<T, StylesBaseConditions>requiredrequired
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
whenmethod can be chained together to build more complex styles.
StylesConditionalStyle
- conditionals
An array of conditional values.
StylesConditionalValue<T, AcceptedConditions>[] - default
The default value applied when none of the conditional values specified in `conditionals` are met.
T
StylesConditionalValue
- conditions
The conditions that must be met for the value to be applied. At least one condition must be specified.
AcceptedConditions - value
The value that will be applied if the conditions are met.
T
StylesBaseConditions
The full set of conditions available for conditional styling. At least one condition must be specified.
- focus
Applies when the component has keyboard or programmatic focus.
true - hover
Applies when the user is hovering over the component with a pointer device.
true - resolution
A minimum device pixel ratio that must be met. Higher values target high-density (Retina) displays.
1 | 1.3 | 1.5 | 2 | 2.6 | 3 | 3.5 | 4 - viewportInlineSize
A minimum viewport inline-size breakpoint that must be met.
{ min: ViewportInlineSize; }
ViewportInlineSize
A keyword that maps to a viewport inline-size breakpoint from the design system. - `extraSmall`: A very narrow viewport, typically small phones. - `small`: A narrow viewport, such as a large phone or small tablet. - `medium`: A medium viewport, such as a tablet in landscape. - `large`: A wide viewport, such as a desktop display.
'extraSmall' | 'small' | 'medium' | 'large'StylesConditions
The set of conditions available for viewport-responsive and interactive styling. At least one condition must be specified.
- focus
Applies when the component has keyboard or programmatic focus.
true - hover
Applies when the user is hovering over the component with a pointer device.
true - viewportInlineSize
A minimum viewport inline-size breakpoint that must be met.
{ min: ViewportInlineSize; }
Anchor to ExamplesExamples
Anchor to Import the StyleHelperImport the Style Helper
Import Style from the UI extensions package to use conditional style values. This example shows the basic import statement for both React and vanilla JS entry points.
Import the Style helper
React
import {
reactExtension,
Style,
View,
} from '@shopify/ui-extensions-react/customer-account';
export default reactExtension('customer-account.page.render', () => (
<Extension />
));
function Extension() {
return (
<View
maxInlineSize={Style.default(200)
.when({viewportInlineSize: {min: 'small'}}, 300)
.when({viewportInlineSize: {min: 'medium'}}, 400)
.when({viewportInlineSize: {min: 'large'}}, 800)}
>
Responsive Content
</View>
);
}JS
import {Style, View, extension} from '@shopify/ui-extensions/customer-account';
export default extension('customer-account.page.render', (root) => {
const view = root.createComponent(
View,
{
border: 'base',
padding: 'base',
maxInlineSize: Style.default(200)
.when({viewportInlineSize: {min: 'small'}}, 300)
.when({viewportInlineSize: {min: 'medium'}}, 400)
.when({viewportInlineSize: {min: 'large'}}, 800),
},
'Responsive Content',
);
root.appendChild(view);
});Anchor to Create responsive grid columnsCreate responsive grid columns
Combine a default style with viewport-based conditions. In this example, the Grid's children stack by default and display side by side on viewports above the small breakpoint.
Create responsive grid columns
React
<Grid
columns={Style.default('fill').when({viewportInlineSize: {min: 'small'}}, [
'30%',
'70%',
])}
>
<View>Content</View>
<View>Content</View>
</Grid>JS
import {Style, Grid, View, extension} from '@shopify/ui-extensions/customer-account';
export default extension('customer-account.page.render', (root) => {
const content1 = root.createComponent(View, {}, 'Content');
const content2 = root.createComponent(View, {}, 'Content');
const grid = root.createComponent(
Grid,
{
columns: Style.default('fill').when(
{viewportInlineSize: {min: 'small'}},
['30%', '70%'],
),
},
[content1, content2],
);
root.appendChild(grid);
});Anchor to Apply hover stylesApply hover styles
Use a simple condition to change styling when a customer interacts with an element. In this example, the View's padding changes to loose on hover.
Apply hover styles
React
<Pressable
onPress={() => alert('press')}
border={Style.default(['base', 'dotted']).when(
{viewportInlineSize: {min: 'small'}},
['base', 'dotted', 'none', 'base'],
)}
>
Content
</Pressable>JS
import {Style, Pressable, extension} from '@shopify/ui-extensions/customer-account';
export default extension('customer-account.page.render', (root) => {
const pressable = root.createComponent(
Pressable,
{
onPress: () => {},
border: Style.default(['base', 'dotted']).when(
{viewportInlineSize: {min: 'small'}},
['base', 'dotted', 'none', 'base'],
),
},
'Content',
);
root.appendChild(pressable);
});Anchor to Conditionally hide contentConditionally hide content
Use the display property with conditional styles to hide content for certain viewport sizes. In this example, the View is hidden on small and larger screen sizes.
Conditionally hide content
React
<View
display={Style.default('auto').when(
{viewportInlineSize: {min: 'small'}},
'none',
)}
>
Content
</View>JS
import {Style, View, extension} from '@shopify/ui-extensions/customer-account';
export default extension('customer-account.page.render', (root) => {
const view = root.createComponent(
View,
{
display: Style.default('auto').when(
{viewportInlineSize: {min: 'small'}},
'none',
),
},
'Content',
);
root.appendChild(view);
});Anchor to Best practicesBest practices
- Start with a default, then add conditions: Always define a base style using
.default()before adding.when()conditions so there's a fallback for every scenario. - Keep conditions simple: Avoid chaining too many
.when()calls. If a style requires more than two or three conditions, consider simplifying the design. - Use viewport conditions for layout shifts: Reserve
viewportInlineSizeconditions for meaningful layout changes like column count, not minor spacing tweaks.
Anchor to LimitationsLimitations
- StyleHelper supports only
hover,focus, andviewportInlineSizeconditions. Other CSS pseudo-classes and media features aren't available. - The viewport breakpoints are limited to
small,medium, andlarge. Custom breakpoint values aren't supported. - StyleHelper can only be used with component properties that accept conditional style values. Not all properties support it.