In magento 2 admin, I want to expandable textarea height using xml. How to do that?

I tried this code. But, it's not working.

<field name="comment">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Comment</item>
                    <item name="formElement" xsi:type="string">textarea</item>
                    <item name="source" xsi:type="string">comment</item>
                    <item name="dataScope" xsi:type="string">comment</item>
                    <item name="cols" xsi:type="number">200</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>

Actual Result :

enter image description here

Expected Result :

enter image description here

  • what is your expected output here? – fmsthird May 2 '19 at 8:31
  • As like screenshot. – Emipro Technologies Pvt. Ltd. May 2 '19 at 8:33
  • ahh.. I think you can define row instead <item name="rows" xsi:type="number">200</item> – fmsthird May 2 '19 at 8:34
  • I mean together with the column you have to define the rows as well – fmsthird May 2 '19 at 8:35
  • Nope. Still, it's not working. – Emipro Technologies Pvt. Ltd. May 2 '19 at 8:36

To increase the height of text-area use <item name="rows" xsi:type="number">60</item> insted of <item name="cols" xsi:type="number">200</item>

But the above code is not working as expected and not increase the height of text-area because of Magento CSS issue. to check inspect element and find class .admin__control-textarea you can see css like below.

.admin__control-textarea {
   height: 8.48rem;
   line-height: 1.18;
   padding-top: .8rem;
   resize: vertical;

In the above CSS you can see CSS height: 8.48rem; just remove this CSS and see your code is working fine so reason for this CSS your code is not working.

To resolve the above issue try with below way :

Add item to your field <item name="additionalClasses" xsi:type="string">md_product_label_uploader</item> for add custom class to your field and apply custom CSS to this field and it will be working fine.

Note : This is default Magento bug I submitted an issue on GitHub.

I hope it helps!

| improve this answer | |
  • 1
    I tried his code in my custom ui form and it works... – fmsthird May 7 '19 at 14:32
  • no I mean his code which he says is not working is working for me. so it is not a default magento bug – fmsthird May 7 '19 at 21:18
  • @magefms check here it is default Magento bug github.com/magento/magento2/issues/22771 I have reported this bug on GitHub – Chirag Patel May 8 '19 at 4:30
  • The height issue appears to have been fixed in Magento, but does anyone have a clue how to pass attributes like rows in custom widget parameters? – ACJ Feb 17 at 12:55

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.