I need to add a custom class to the country and state select box container in all forms expecially in shipping and billing address form on frontend?


Open file or override checkout


search for the line <item name=”country_id” xsi:type=”array”> and

add class <item name="class" xsi:type="string">the-class</item>


add class at checkout page


<type name="Magento\Checkout\Block\Checkout\AttributeMerger">
    <plugin name="customAttributeMerger" type="VendorNameSpace\Module\Plugin\AttributeMergerPlugin"/>

AttributeMergerPlugin.php VendorNameSpace\Module\Plugin

namespace VendorNameSpace\Module\Plugin;

class AttributeMergerPlugin
    public function afterMerge(\Magento\Checkout\Block\Checkout\AttributeMerger $subject, $result)
        // add Additional class for country
        if (array_key_exists('country_id', $result)) {
              $result['country_id']['additionalClasses'] = 'custom-class-country';
        // add Additional class for city
        if (array_key_exists('city', $result)) {
            $result['city']['additionalClasses'] = 'cusotom-city';

        return $result;

Hope this will help you. thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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