Changing the color of a button if it is disabled

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
Krisztyan
Posts: 35
Joined: 19 Jan 2021, 21:16

06 May 2021, 12:26

Hi Guys,

I am using Rain theme. I would like to change the color of my button if it disabled.
I would like to change the color of the button to light grey if it is disabled. If it is not disabled it is red.

Can please someone tell me how to do that?

<p:commandButton id="cancelButton"
value="#{msg['prod.cancel']}"
icon="fas fa-undo" styleClass="danger-button p-mr-2"
style="width:auto;" ajax="true" update="update"
actionListener="#{cancelProd}"
disabled="#{!prod.isCancelable()}">
<p:confirm
...etc>
</p:commandButton>

Many thanks and best regards,
Krisztyan

Primefaces version: 8.0.4
Rain theme: 1.0.0

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

07 May 2021, 08:14

Hi,

Please try;

Code: Select all

<p:commandButton styleClass="#{!prod.isCancelable() ? 'custom-light-grey' : 'danger-button'} p-mr-2" disabled="#{!prod.isCancelable()}">
Best Regards,

Krisztyan
Posts: 35
Joined: 19 Jan 2021, 21:16

07 May 2021, 10:27

Hi Mert Sincan,

thank you for your help. Now the color of the button is light grey as expected.

Unfortunately now I lost the margin to the right. p-mr-2 not recognized.
I have two buttons next to each other in the same line horizontally and there is no margin between them anymore.

The styleclass of the two buttons are the same.

Like:

Code: Select all


First:
styleClass="#{!prod.isCancelable() ? 'custom-light-grey' : 'danger-button'} p-mr-2}" disabled="#{!prod.isCancelable()}">	
Second:
styleClass="#{!prod.isCancelable() ? 'custom-light-grey' : 'danger-button'} p-mr-2}" disabled="#{!prod.isCancelable()}">	

																
										
Could you please help with that?

Many thanks and best regards,
Krisztyan

Krisztyan
Posts: 35
Joined: 19 Jan 2021, 21:16

07 May 2021, 11:37

Ahhh OK got it. I had a } in the expression.

Super thanks for your help!

siris
Posts: 322
Joined: 29 Jul 2019, 13:57

07 May 2021, 16:09

Thanks @mert.sincan

Post Reply

Return to “Rain - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests