• Services

    IT SERVICES

    solutions for almost every porblems

    Ecommerce Development

    Enterprise Solutions

    Web Development

    Mobile App Development

    Digital Marketing Services

    Quick Links

    To Our Popular Services
  • Hire Developers

    Hire Developers

    OUR ExEPRTISE, YOUR CONTROL

    Hire Mangeto Developers

    Hire Java Developers

    Hire Node Developers

    Hire Shopify Developers

    Hire Android Developers

    Hire Angular Developers

    Hire Shopware Developers

    Hire iOS App Developers

    Hire WordPress Developers

    Hire A full Stack Developer

    Choose a truly all-round developer who is expert in all the stack you require.

  • Case Studies
  • About
  • Blog
  • Contact Us
How to add custom styles (Colors and Fonts) to Magento Admin Grid
Updated on 08/08/2024

How to add custom styles (Colors and Fonts) to Magento Admin Grid

ecommerce Magento Technical

Customizing the Magento 2 admin grid by adding colors based on specific conditions, such as order status or company name, can significantly enhance usability and readability. In this tutorial, we’ll explore how to add CSS classes to the Magento 2 admin grid, which allows for dynamic styling based on the data in each row. This guide builds on a previous tutorial where we created a custom data provider for the admin grid.

You can download the base module form the below link:

Download the Starter Module

Full Video Walkthrough by CodeWithAli

Extend the Listing Component

To begin, you’ll need to extend the default listing component in Magento 2. Create the listing.js inside view/base/web/js/grid/.

Copy the following code which extends and override the default functionality

Click here to view and edit & add your code between the textarea tags

Checkout our super useful Magento 2 Extensions

Referencing the Listing component

We need to add this XML code to our column structure inside the column component located at view/adminhtml/ui_component/grids_custom_customdataprovider_list.xml.

Click here to view and edit & add your code between the textarea tags

adding function to listing component

Let’s add some logic for dynamically adding custom class to our listing template.

Click here to view and edit & add your code between the textarea tags

Creating the template file

Create a new template file named listing.html inside view/base/web/templates/grid

To customize the grid, create a new template file by copying the default template and modifying it to include custom function that we created in the previous step. 

Click here to view and edit & add your code between the textarea tags

Creating less file to add styles

With the classes in place, you can now add custom CSS to style the grid. Create a LESS file under web/css/source/_module.less.

Click here to view and edit & add your code between the textarea tags

Hire dedicated Magento Developers

Compile and View Changes

After setting up the CSS and templates, recompile your Magento 2 theme and clear the cache to ensure that the changes are applied correctly.

Click here to view and edit & add your code between the textarea tags

Debugging Tips

Below are some of the common mistakes that happens while writing the code, so if your code does not work, do checkout the following things

  • Ensure all files are correctly placed in the appropriate directories. 
  • If the classes or styles aren’t applying, double-check the file structure and clear the cache.
  • Ensure the file names and paths match those referenced in your JavaScript and template files.

Congratulations! you added an awesome Magento skill in your arsenal

This was just a tip of iceberg of what you can do with this technique. This approach can be customized further based on your specific needs, whether you’re highlighting order statuses, customer information, or any other data. This method works not only for custom admin grids but can also be applied to predefined grids like order or customer grids.

Would you like to share this article?

Share

If you need any assistance regarding Magneto 2 frontend or backend customizations

Feel Free to Contact Our Certified Experts

All Categories

Artificial Intelligence
ChatGPT
Communication
ecommerce
Magento
News and Updates
Technical
UX and Navigation
WhatsApp API

Latest Post

  • Magento 2 Rich Text Schema Setup in JSON-LD: Step-by-Step Guide
  • Fixing Magento 2 Product Schema Markup | Missing “image” field FIX
  • How to Dispatch Custom Events in Magento 2
  • Adding Filters in Magento Admin Grid | Column and Non-Column Component
  • How to add custom styles (Colors and Fonts) to Magento Admin Grid

Related Post

  • Magento 2 Rich Text Schema Setup in JSON-LD: Step-by-Step Guide
  • Fixing Magento 2 Product Schema Markup | Missing “image” field FIX
  • How to Dispatch Custom Events in Magento 2
  • Adding Filters in Magento Admin Grid | Column and Non-Column Component
  • Introduction to Events and Observers in Magento 2

310 Kuber Avenue, Near Gurudwara Cross Road, Jamnagar – 361008

Plot No 36, Galaxy Park – II, Morkanda Road,
Jamnagar – 361001

Quick Links

  • About
  • Career
  • Case Studies
  • Blog
  • Contact Us
  • Privacy Policy
Icon-facebook Linkedin Google Clutch Logo White

Our Expertise

  • eCommerce Development
  • Web Development Service
  • Enterprise Solutions
  • Mobile App Development
  • Digital Marketing Services

Hire Dedicated Developers

  • Hire Full Stack Developers
  • Hire Certified Magento Developers
  • Hire Top Java Developers
  • Hire Node.JS Developers
  • Hire Angular Developers
  • Hire Android Developers
  • Hire iOS Developers
  • Hire Shopify Developers
  • Hire WordPress Developer
  • Hire Shopware Developers

Copyright @Azguards Technolabs 2025 all Rights Reserved.