General

All You Need to Know About Customize a Theme’s Styles in Magento

Howdy Magento Folks?,

Are you all ready to learn new? I am hearing a big yes from your side. As always welcome to Magento Tutorial blog. Today I am here to illustrate to you all about customizing a themeā€™s styles in Magento. Also, go through our latest published article How to Create your Own Custom Theme in Magento 2. Letā€™s dive in?

Introduction:

Magento themes are very essential for the E-commerce merchants to advance the look of their store. Mainly, one can also customize the themes installed in the Magento store. If you think that your installed theme is not sufficient to attract your users then there is a chance of losing all your customers also. Looking forward to helping you customize your theme. For PSD to Magento Theme Conversion visit PSD to Magento Theme Conversion Service which will help you in improving your website design.

Steps to customize a themeā€™s styles in Magento:

Extend parent styles

For extending parent themeā€™s styles.

Step 1: Firstly create a web/css/source sub-directory in your theme directory. After that, you will need to create a _extend.less file at that place. Refer to the given below path for the same.

<theme_dir>/web/css/source/_extend.less

Now here you have to add your less code in this file. The quick and easiest way to extend the theme with the help ofĀ  _extend.less.

Override parent styles

Here for overriding parent styles, one has to override the default Magento UI library variables.

Step 1: Firstly Create web/css/source sub-directory in your theme directory. Now, create here a _theme.less file with reference to below path

<theme_dir>/web/css/source/_theme.less

Step 2: Make sure that your _theme.less overrides the parent _theme.less. You can now make a copy of all that variables that you require and also which are not going to change.Ā 

The only disadvantages of this process are you will surely require for manually updating and tracking all your files every time the parentā€™s _theme.less is updated

Adding structured changes

Here the use of button component is applied in _button.less as an example. For changing structure you have to separately add an overriding or extending .less files for every Magento UI library component you change.

Extend the componentā€™s styles

Step 1: Create eb/css/source sub-directory and add _buttons_extend.less and _extend.less here refer the below path forĀ 

<theme_dir>web/css/source/ā”œā”€ā”€_buttons_extend.less

ā”‚Ā  Ā  Ā  ā”‚Ā  ā”‚ Ā  ā”‚ Ā  Ā  Ā  ā”œā”€ā”€_extend.less

Step 2: Add your desired styles button component in _buttons_extend.less.

Step 3: In _extend.less register the _buttons_extend.less by adding the following code: @import ā€˜https://qt.flikover.com/api/report/get/_buttons_extend.lessā€™;

Override componentā€™s styles

Step 1: For the buttons of your theme you need to override the parent themeā€™s styles

Step 2: Create create a web/css/source sub-directory in your theme directoryĀ 

Step 3: Create a _buttons.less file here and the path to that is given below.

<theme_dir>/web/css/source/_buttons.less

Hence this file will override the parent theme file _buttons.less.

Extend module styles

For extending the modules styles in your theme.

Step 1: Create Module_Name/web/css/source directory and create an _extend.less file in the theme directory

<theme_dir>/<module_dir>/web/css/source/_extend.less

You can also add additional styles in _extend.less file.

Override module styles

For overriding module sį¹­yles in your theme:

Step 1: Create Module_Name/web/css/source directory and create a _module.less file.Ā 

<theme_dir>/<module_dir>/web/css/source/_module.less

This file overrides the _module.less file and you can add your styles here.

Final Words:

Hopefully, with the help of the above solution, you will be able to customize your theme in Magento. In case any trouble does comment down in the comment section below. Do not forget to share with your Magento developer friends.

Happy Coding?

Click to rate this post!
[Total: 7 Average: 4.4]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate šŸŽ–ļø Certified Magento DeveloperšŸ‘Øā€šŸ’». He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fondā¤ļø of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.šŸ

View Comments

  • What?

    Step 3: In _extend.less register the _buttons_extend.less by adding the following code: @import ā€˜https://qt.flikover.com/api/report/get/_buttons_extend.lessā€™;

Recent Posts

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

2 days ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

5 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

7 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

7 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

1 week ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

1 week ago