Learn how to set specific styles for your store components to enhance your store's user experience.
After understanding blocks and templates and how they render interface components, this guide will show you how to customize them to match your store identity.
The Store Theme allows you to:
- Set a default style for all store components
- Set a specific style for a component type or a single component
Setting a default style for all store components
To set the default style for your store, you can use the style.json
file in the style
folder of the Store Theme app. This single file allows you to customize the appearance of your store by modifying the default definitions declared within it. This approach avoids the need to customize individual components on each page.
For example, you can set the default theme background color to blue by changing the semanticColors
block's base
property:
_21"semanticColors": {_21 "background": {_21 "base": "#00BFFF",_21 "base--inverted": "#03044e",_21 "action-primary": "#0F3E99",_21 "action-secondary": "#eef3f7",_21 "emphasis": "#f71963",_21 "disabled": "#f2f4f5",_21 "success": "#8bc34a",_21 "success--faded": "#eafce3",_21 "danger": "#ff4c4c",_21 "danger--faded": "#ffe6e6",_21 "warning": "#ffb100",_21 "warning--faded": "#fff6e0",_21 "muted-1": "#727273",_21 "muted-2": "#979899",_21 "muted-3": "#cacbcc",_21 "muted-4": "#e3e4e6",_21 "muted-5": "#f2f4f5"_21 },_21}
The
styles.json
file only accepts HEX values to set a color. Using other formats, such as RGB, may break the PWA module.
For detailed instructions on customizing your theme, see the VTEX Styleguide, a comprehensive CSS framework with guidelines for defining component styles. It includes a detailed explanation of the styles.json
file structure to help you in your customizations.
Setting a specific style for a component type or a single component
The style.json
file enables more generic customization of your store visual style and can be useful in most scenarios.
If you want to create a more distinctive store identity with certain elements featuring unique styles different from the default theme, consider this scenario: Imagine your store primarily uses blue as its main color, but you want the text components (created by rich-text
blocks) to display in red. To make only one specific text component red while keeping the rest in the default blue color, you can achieve this advanced customization by overriding the default styles defined in styles.json
. This can be done using CSS handles and the blockClass
prop.
To apply advanced customization to your store style, see the guide Using CSS Handles for store customization.