Learn how to set specific styles for your store components to enhance your store's user experience.
Your website’s visual style is fundamental to building your store’s identity.
Once you understand what blocks and templates are and how they render interface components, it’s time to learn how to customize them.
The Store Theme allows you to:
- Set a default style for all your store components.
- Set a specific style for a store component type or a single component from all available in your store.
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 that provides 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 allows for more generic customization of your store’s visual style and can be useful in most scenarios.
However, if you want a more distinctive store identity, where certain components have unique styles different from the default theme, consider the following scenario: Suppose your store primarily uses blue as its main color, but you want the text components (rendered by rich-text
blocks) to display in red. Now, let's say you want only one specific text component to be red while the rest remain in the default blue color. To achieve such advanced customization, you can override the default style defined in styles.json
with CSS handles and use the blockClass
prop for the last example.
If you are interested in applying advanced customization to your store style, see the guide Using CSS Handles for store customization for more instructions.