Skip to Content

How do I know if it is possible to set colors ?

Dec 29, 2017 at 11:30 AM


avatar image

Hi all,

Here's what I have

Part of the code from View.xml

<TreeTable ...
<Column width="9rem">
     <m:Label text="Price"/>
             <u:Currency value="{amount}" currency="{currency}"/>

I want the values in the fields "value" and "currency" had color.

I need to use sap.m.ValueColor, but API sap.ui.unified.Currency have nothing to do this.

Can I do it here? Or need to use a more suitable container? For example:

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Iftah Peretz
Dec 30, 2017 at 04:20 PM


Here is the parallel to sap.m.ValueColor and the part of the XML to change

sapUiIconColorCritical    Yellow   = sap.m.ValueColor.Critical
sapUiIconColorNeutral     Grayish  = sap.m.ValueColor.Neutral
sapUiIconColorPositive    Green    = sap.m.ValueColor.Good
sapUiIconColorNegative    Red      = sap.m.ValueColor.Error
<u:Currency class="sapUiIconColorPositive" value="{amount}" currency="{currency}"/>
Show 6 Share
10 |10000 characters needed characters left characters exceeded

Hi, Iftan Peretz
Thank you, this is what I need.

But, where did you get this information? The fact is that now, I need to set the color for sap.m.Text

 <Column id="colCategories" width="13rem">
     <m:Label text="Categories"/>
             <m:Text id="txtColumnCategories" text="{name}" wrapping="true"/>

But I can't find a suitable class

<m:Text class="myText" text="{name}" wrapping="true"/>

.myText {
    color: red;

Thanks again, you helped me!

Could you explain to me?

In the first case we use a predefined class. But how to understand it? And Where to find the documentation for the classes?

In the second case, we use a custom class. But how to understand or distinguish what it is?


Hi Roman,

The second approach (the one with your own class, in our case .myText) would work for both cases, meaning you can always define a style class of your own, of course, it could be more than one (so one for the currency and one for the text, in your case).

Because you asked for a specific color pattern (in you question "sap.m.ValueColor") I looked for that match. I did it by going over "library.css" file - I know it is there based on Chrome debugger and from experience.

As for the custom CSS class, same thing here, personal experience and Google (there is a lot out there).

There is even a predefined CSS custom-able SAP class.

I hope I answered your question and If so I urge you to mark the answer as correct and close the question.


Yes, you fully answered my questions.

But why, the predefined class is not working for the second example(sap.m.Text). The fact that HE (sap.m.Text) is not in the library or something?


Sorry, I don't understand what you are asking.