0

How can I apply CSS Styles to an Aura button? Here is the code:

HTML:

<lightning:button class="other-devices-button" label="Close" title="Close action" onclick="{! c.closeModalOtherDevices }"/>

CSS:

    .THIS .other-devices-button{
        
            --sds-c-button-brand-color-background: purple;
        
}

It does not work.

0

yes you can try this :

<lightning:button label="Close" title="Close action" onclick="{! c.closeModalOtherDevices }" class="other-devices-button"/>

and go to your css file :

.THIS .uiButton.other-devices-button{
   background-color: #E6E6FA    ;
   padding: 10px 20px;
}
1
  • Still not working... – CPS Apr 15 at 8:12
0

As far as I'm aware, the new CSS Style Hooks only work in LWC, not Aura. You'd need to write a custom LWC component to engage with this feature.

0

You can change the color by following below line of .Cmp and Style file.

<lightning:button class="other-devices-button" label="Close" title="Close action"/>

Please add space in between .THIS and your class name .other-devices-button

.THIS .other-devices-button { background-color: red ; padding: 10px 20px; }

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.