Thursday, August 04, 2016

Style like Homepage in Salesforce

The requirement is to create visualforce and make it as one of Homepage component.The style should be same as Homepage style.

It works until a user comes to me and said;

"I notice the blue section in the component is different from Homepage component."

Krik... Krikk.. I didn't notice that until I have to print screen and put it side to side.Oh,actually it is different, I thought it just screen reflection.So how can I get the Homepage style color.

This is my page definition,note I use tabStyle = Account .So it gives me the blue color same like Account tab.

<apex:page controller="MyController" readOnly="true" showHeader="false" standardStylesheets="true" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">    
<apex:pageBlock title="My Account" tabstyle="Account">

By default if we are not defining the tabStyle,it will use Homepage style ...but in my case it gives me black color.

In order to get the Homepage style I need to set showHeader="true"  , by default showHeader is true except for Salesforce1 and Lightning Experience.Remember to remove applyHtmlTag when we set showHeader="true".

The modified code is

<apex:page controller="MyController" readOnly="true" showHeader="true" standardStylesheets="true" sidebar="false"  docType="html-5.0">  
<apex:pageBlock title="My Account" >
Now it gives me the same blue.

Have a nice day.

No comments:

Post a Comment