Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento 2 - How to change htmlClass, htmlId attributes by referenceContainer or another way?

In magento 2 Frontend developer guide, I have read that :

Certain attributes, like htmlClass, htmlId, label attributes can be changed in extending layouts

I want to change htmlClass of the container defined in 1column.xml. Could you tell me how to do it by referenceContainer or another way ?

I used : (both html_class & htmlClass)

<arguments>
            <argument name="html_class" xsi:type="string">sm-page-header</argument>
</arguments>

but not affected

Thanks!

like image 823
Tung Nguyen Avatar asked Dec 09 '22 00:12

Tung Nguyen


1 Answers

If a container is declared in xml with the following code:

<container name="my.container" htmlTag="div" htmlClass="old-class">
    <...>
</container>

You can simply override the css-class by placing the following code somewhere in your extending layout files:

<referenceContainer name="my.container" htmlClass="new-class" />
like image 54
Quinten Avatar answered May 12 '23 04:05

Quinten