How To

Magento 2: How to Change Order Status Text Color in Admin UI Component Grid

Hello Magento Friends,

Today we will learn Magento 2: How to Change Order Status Text Color in Admin UI Component Grid.

Order status is a part of the order processing workflow that describes the stage of a particular order. The Magento 2 Sales Order Grid has many order statuses like Processing, Closed, Pending, Complete. Magento 2 Admin can even

The default sales order grid displays the order status in black color. To differentiate amongst various order status you can add background color and text color to the order status in Magento 2.

Let’s find out How to Change Order Status Text Color in Admin UI Component Grid in Magento 2

Steps to Change Order Status Text Color in Admin UI Component Grid in Magento 2:

Step 1: Move to the below path

app\code\Vendor\Extension\view\adminhtml\ui_component\sales_order_grid.xml

And add the code mentioned below

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <columns name="sales_order_columns">
        <column name="status" component="Vendor_Extension/js/grid/columns/custom">
            <settings>
                <filter>select</filter>
                <options class="Magento\Sales\Ui\Component\Listing\Column\Status\Options"/>
                <dataType>select</dataType>
                <label translate="true">Status</label>
            </settings>
        </column>
    </columns>
</listing>

Step 2: Next, go to the following path

app\code\Vendor\Extension\view\adminhtml\layout\sales_order_index.xml

Add the below-mentioned code

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="styles"/>
    <head>
        <css src="Vendor_Extension::css/custom.css" />
    </head>
    <body>
        <referenceContainer name="content">
            <uiComponent name="sales_order_grid"/>
        </referenceContainer>
    </body>
</page>

Step 3: Then, go to the below file path

app\code\Vendor\Extension\view\adminhtml\web\js\grid\columns\custom.js

Now, add the code

define([
'underscore',
'Magento_Ui/js/grid/columns/select'
], function (_, Column) {
'use strict';

return Column.extend({
defaults: {
bodyTmpl: 'Vendor_Extension/ui/grid/cells/text'
},
getOrderStatusColor: function (row) 
{
    if (row.status == 'pending') 
    {
        return 'pending-status';
    } else if(row.status == 'processing') 
    {
       return 'processing-status';
    } else if(row.status == 'complete') 
    {
       return 'complete-status';
    } else if(row.status == 'closed') 
    {
       return 'closed-status';
    }
    return '#303030';
}
});
});

Step 4: Now, move to the below path

app\code\Vendor\Extension\view\adminhtml\web\template\ui\grid\cells\text.html

And add the code as follows

<div class="data-grid-cell-content" data-bind="attr: { class: $col.getOrderStatusColor($row())}" text="$col.getLabel($row())"/>

Step 5: Finally, go to the below path

app\code\Vendor\Extension\view\adminhtml\web\css\custom.css

Lastly add the below code

.pending-status {
    background: #FFB347 none repeat scroll 0 0;
    border: 1px solid #eb5202;
    color: #eb5202;
    display: block;
    font-weight: bold;
    line-height: 17px;
    padding: 0 3px;
    text-align: center;
    text-transform: uppercase;
}
.processing-status {
    background: #E5F7FE none repeat scroll 0 0;
    border: 1px solid #006bb4;
    color: #006bb4;
    display: block;
    font-weight: bold;
    line-height: 17px;
    padding: 0 3px;
    text-align: center;
    text-transform: uppercase;
}
.complete-status {
    background: #d0e5a9 none repeat scroll 0 0;
    border: 1px solid #5b8116;
    color: #185b00;
    display: block;
    font-weight: bold;
    line-height: 17px;
    padding: 0 3px;
    text-align: center;
    text-transform: uppercase;
}
.closed-status {
    background: #f9d4d4 none repeat scroll 0 0;
    border: 1px solid #e22626;
    color: #e22626;
    display: block;
    font-weight: bold;
    line-height: 17px;
    padding: 0 3px;
    text-align: center;
    text-transform: uppercase;
}

Step 6: Once you are done with the above changes, kindly run the below command

sudo php bin/magento setup:upgrade
sudo php bin/magento setup:static-content:deploy -f
sudo php bin/magento cache:flush

Now check the result from the Magento Admin Panel. You can see the Order Status Text Colour has been changed.

Conclusion:

Hopefully, all were able to Change Order Status Text Color in Admin UI Component Grid in Magento 2. If you face any issue with the implementation of the above steps, just mention it in the comment box. If you found the article helpful, share it with your Magento Buddies.

Happy Coding

Click to rate this post!
[Total: 7 Average: 4.1]
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

  • Hi,
    warning line 19 : app\code\Vendor\Extension\view\adminhtml\web\js\grid\columns\custom.js

    Replace return 'closed-status’; -> return 'closed-status';

Recent Posts

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

2 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

2 days ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

2 days ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

4 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We're thrilled to announce the release of Hyvä Themes 1.3.6 and 1.3.7! These latest updates…

5 days ago

How Modern E-Commerce Platforms Leverage Docker & Kubernetes for Scalability

Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…

6 days ago