Documentation
Feedback
Guides
Learning Center

Learning Center
Learning Center
Global Styles
View in Portuguese
This content was migrated from the VTEX Learning Center and is no longer being actively maintained. For the most accurate and up-to-date information, please check the official documentation.

Introduction

In addition to css, which we looked at previously, Store Framework offers another type of design customization, based on style.json.

Semantic styling

Every Store Framework block benefit from the same semantic styles definitions, based on Tachyons. In practice, it means that instead of having to change all button backgrounds to use color that you want, you just need to redefine the color of an action-primary background. Customizations using style.json tend a very big impact through css, since the store's visual identity across every page is usually maintained that way, without requiring a lot of changes. Therefore, use this tool whenever possible, thus avoiding unnecessary css overhead.

Investigating style.json

Colors

{"base64":"  ","img":{"width":986,"height":860,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":146976,"url":"https://user-images.githubusercontent.com/18701182/69848546-24fa6380-1259-11ea-9978-9020222ed77e.png"}}

styles/configs/style.json can be confusing at first, because it contains all the style definitions that every Store Framework visual block uses. However, inspecting browser elements is usually a good way to identify which styles to change. For example, right mouse click on any store button and select inspect.

{"base64":"  ","img":{"width":914,"height":254,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":202774,"url":"https://user-images.githubusercontent.com/19495917/90169302-cb997c80-dd74-11ea-983e-6af755b1aa5d.png"}}

Looking at the side bar that opened in Chrome, we notice a couple of definitions, one of them being the text color (#3f3f40):

{"base64":"  ","img":{"width":554,"height":727,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":109570,"url":"https://user-images.githubusercontent.com/19495917/90169845-875aac00-dd75-11ea-968b-db03f14435e7.png"}}

If we search the occurrences of this color in style.json, we uncover that the color we inspected are actually used as base, for example. This gives us a better idea of where this definition may appear again.

Typography

The process to discovering text semantics with editable fields is the same as the above, we can search for attributes such as font size, weight and family. When inspecting a level 1 heading for example, we notice that its size is 3 rem.

{"base64":"  ","img":{"width":566,"height":67,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":8154,"url":"https://user-images.githubusercontent.com/19495917/90170621-b0c80780-dd76-11ea-9d41-c96639944e58.png"}}

{"base64":"  ","img":{"width":342,"height":228,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":21984,"url":"https://user-images.githubusercontent.com/19495917/90170541-9b52dd80-dd76-11ea-8390-f243e267e145.png"}}

Globally changing color and typography

  1. In style.json, replace every color occurrence that you find, substituting:
  • #3f3f40 with #e68e94
  1. Change the font size for a level 1 heading so that its height is now 2.5 rem:


    _10
    "heading-1": {
    _10
    "fontFamily": "Fabriga, -apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue, helvetica, ubuntu, roboto, noto, segoe ui, arial, sans-serif",
    _10
    "fontWeight": "700",
    _10
    + "fontSize": "2.5rem",
    _10
    "textTransform": "initial",
    _10
    "letterSpacing": "0"
    _10
    },

The expected result is as it follows:

{"base64":"  ","img":{"width":1920,"height":976,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":1231978,"url":"https://user-images.githubusercontent.com/19495917/90172958-17025980-dd7a-11ea-80d1-31b6e3f3ac1f.png"}}

Answer sheet

See answer sheet for style.json
style.json

_59
{
_59
"background": {
_59
"base": "#ffffff",
_59
"base--inverted": "#03044e",
_59
"action-primary": "#52BAB7",
_59
"...": "..."
_59
},
_59
"hover-background": {
_59
"action-primary": "#45a6a3",
_59
"action-secondary": "#dbe9fd",
_59
"...": "..."
_59
},
_59
"text": {
_59
"action-primary": "#52BAB7",
_59
"action-secondary": "#eef3f7",
_59
"link": "#52BAB7",
_59
"...": "..."
_59
},
_59
"hover-text": {
_59
"action-primary": "#45a6a3",
_59
"action-secondary": "#dbe9fd",
_59
"...": "..."
_59
},
_59
"border": {
_59
"action-primary": "#52BAB7",
_59
"action-secondary": "#eef3f7",
_59
"...": "..."
_59
},
_59
"hover-border": {
_59
"action-primary": "#45a6a3 ",
_59
"action-secondary": "#dbe9fd",
_59
"...": "...",
_59
"action-primary": "#ffffff",
_59
"action-secondary": "#52BAB7",
_59
"emphasis": "#ffffff",
_59
"...": "..."
_59
},
_59
"on": {
_59
"base": "#e68e94",
_59
"base--inverted": "#ffffff",
_59
"action-primary": "#ffffff",
_59
"action-secondary": "#0F3E99",
_59
"...": "..."
_59
},
_59
"active-on": {
_59
"action-primary": "#ffffff",
_59
"action-secondary": "#52BAB7",
_59
"emphasis": "#ffffff",
_59
"...": "...",
_59
"heading-1": {
_59
"fontFamily": "Fabriga, -apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue, helvetica, ubuntu, roboto, noto, segoe ui, arial, sans-serif",
_59
"fontWeight": "700",
_59
"fontSize": "2.5rem",
_59
"textTransform": "initial",
_59
"letterSpacing": "0"
_59
},
_59
"...": "..."
_59
}
_59
}

On this page