48
Views
9
Comments
Solved
Dynamic update CSS class using input from screen
Application Type
Reactive
Service Studio Version
11.55.15 (Build 64075)

I have a Status class defined in my theme module stylesheet and that Status class is utlizied on container/widgets in other modules. 

Now, I have a screen where the Status class name will be displayed and on clicking on that user can modify the css (For example - entering color code in input) and on clicking on save I want to update that particular Status class with new css. How to do that ?

For example - 

Success Container Class before update - 

.successcontainer

{

    color:  #172b4d; 

}


Success Container Class after update - 

.successcontainer

{

    color:  #42526E; 

}

2019-11-11 17-10-24
Manish Jawla
 
MVP
Solution

Hi @Bhanu Pratap 

Here is the sample oap.

Hope this helps.

Regards,

Manish Jawla

ChangeCss.oap
2024-10-09 04-44-30
Bhanu Pratap

Thanks, I'll check this.

2024-10-09 04-44-30
Bhanu Pratap

Thanks @Manish Jawla, Your solution is what I wanted.

2019-11-11 17-10-24
Manish Jawla
 
MVP

Great :) happy to help you. I believe that this solution will work in your scenario. 

2019-11-11 17-10-24
Manish Jawla
 
MVP

Hi @Bhanu Pratap ,

In order to achieve this, you need to use Css variable inside your class.

For reference you can refer my component from forge:

https://www.outsystems.com/forge/component-overview/21137/sidebar-collapse-layout-o11 

I am changing the value of left menu variable for spacing here using simple JavaScript, you can do the same for Css as well.

Hope this helps.

Regards,

Manish Jawla

2024-10-09 04-44-30
Bhanu Pratap

Hi @Manish Jawla,

Thank you for the reply.

Sure I'll check the component logic if that works for my usecase.

2019-11-11 17-10-24
Manish Jawla
 
MVP
Solution

Hi @Bhanu Pratap 

Here is the sample oap.

Hope this helps.

Regards,

Manish Jawla

ChangeCss.oap
2024-10-09 04-44-30
Bhanu Pratap

Thanks, I'll check this.

2024-10-09 04-44-30
Bhanu Pratap

Thanks @Manish Jawla, Your solution is what I wanted.

2019-11-11 17-10-24
Manish Jawla
 
MVP

Great :) happy to help you. I believe that this solution will work in your scenario. 

2022-12-22 10-00-39
Beatriz Sabino

Hi Bhanu,

Like Manish mentioned, you can change the CSS property using a JavaScript node in your action.

To change the color property of a CSS class you can use: 

 document.getElementById(@Id).style.color=@UserInput;

2024-10-09 04-44-30
Bhanu Pratap

Hi @Beatriz Sabino,

Thanks for the reply.

Let me try that as well if it works then will let you know here.

2024-10-09 04-44-30
Bhanu Pratap

@Beatriz Sabino, Manish solution is more effective for my usecase. Thanks

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.