5

How to override default blank theme less variable value? Generally veriable are declare in lib\web\css\source\lib\variables directory.
i.e from file
lib\web\css\source\lib\variables_typography.less

@font-family__sans-serif: 'Helvetica Neue', Helvetica, Arial, sans-serif;
@font-family__serif: Georgia, 'Times New Roman', Times, serif;
@font-family__monospace: Menlo, Monaco, Consolas, 'Courier New', monospace;

@font-family__base: @font-family__sans-serif;

I want to change value of above attribute.

  • From where can I override these varable?
  • How can I change font-family in body?

1 Answer 1

5

You can override default less variables in your custom theme. In <magento-root>/lib/web/css/source/lib/variables/ you will find a number of LESS files.

In each of these you can find values assigned to variables for many of the common elements in Magento 2.

To override any of these variables, simply create a less file in your custom theme and update the variable like below.

app/design/frontend/{Namespace}/{theme}/web/css/source/_theme.less

//  Font families
@font-family__sans-serif: 'Helvetica Neue', Helvetica, Arial, sans-serif;
@font-family__serif: Georgia, 'Times New Roman', Times, serif;
@font-family__monospace: Menlo, Monaco, Consolas, 'Courier New', monospace;

Kindly refer to below links for more detail.

https://magento.stackexchange.com/a/110165/23943 https://magento.stackexchange.com/a/109808/23943

1
  • Is this doable without having to ensure you have all variables from the parent? Commented Jan 13, 2019 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.