function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DannyK89DannyK89 

Using Style to make a command link look like a command button.

I would like a command like to look like a command button. I was once told that I could to that with using the style but I am having trouble figureing out how to do it. Can anyone give me a hand. Thanks

Best Answer chosen by Admin (Salesforce Developers) 
fsdafdsfsdfsafsdafdsfsdfsa

you can use the styleClass="btn" attribute which will inherit the salesforce buton styles. You might need to use some CSS beyond that to make them an exact match but that should get you 90% of the way there.

All Answers

fsdafdsfsdfsafsdafdsfsdfsa

you can use the styleClass="btn" attribute which will inherit the salesforce buton styles. You might need to use some CSS beyond that to make them an exact match but that should get you 90% of the way there.

This was selected as the best answer
ShuchiMShuchiM

That was so useful !

For my piece of code, i wanted to make a normal input type="button" look like a command button and i used:

input type="button" class="btn"

 

and that seemed to work. Thanks !


fsdafdsfsdfsa wrote:

you can use the styleClass="btn" attribute which will inherit the salesforce buton styles. You might need to use some CSS beyond that to make them an exact match but that should get you 90% of the way there.



JohnBrandoliniJohnBrandolini

Genius!  Thanks, this was perfect.

JohnBrandoliniJohnBrandolini

The only additional thing I had to do was add text-decoration:none; to the css style of the link.  I did this per link because I didn't want to create a whole class for it, but easily could have.

zachbarkleyzachbarkley

We wanted a link in an iframe to redirect parent. Code below matched standard button:

 

<apex:commandLink target="_top" styleClass="btn" style="text-decoration:none;padding:4px;" action="{!URLFOR($Action.MyObject__c.MyNewButton, Id)}" value=" My Custom Button "/>

Sure@DreamSure@Dream
Thank u guys..!! :)
Chirag MehtaChirag Mehta
For lightning, please use below:

<apex:commandLink target="_top" styleClass="slds-m-top_xx-small slds-button slds-button_neutral btnSubmit" style="margin:0 auto;" action="{!URLFOR($Action.Acount.View, $CurrentPage.Parameters.Id)}" value="Back"/>