A lesser known Visualforce pageBlock attribute called “mode”

For those of you who create Visualforce pages to extend default Salesforce functionality, and who want to be as close to the standard layouts of the user interface, this little baby might come in handy to know!

When you create a pageBlock in VisualForce, you might have noticed that the background is LIGHT GRAY when viewing or editing fields, but if you use the standard edit function for an object, the background is WHITE!

How do you make sure that your VisualForce page uses the same layout styles and properties as native Salesforce functionality?

Well, pageBlock comes with an attribute that is not really well documented, called “mode”.

This value determines whether lines are drawn to separate field values. Possible values are:

  • “detail”, in which data is displayed to the user with colored lines
  • “edit”, in which data is displayed to the user without field lines. If not specified, this value defaults to “detail”. These lines have nothing to do with requiredness, they are merely visual separators, that make it easier to scan a detail page.
  • “maindetail”, in which data is displayed to the user with colored lines and a white background, just like the main detail page for records

Here is a screenshot of the three modes:

“detail” (default if you don’t use the mode attribute):

Visualforce pageBlock attribute


VF PageBlock Mode Edit


VF PageBlock Mode MainDetail

More info can be found on this attribute in the official developer documentation: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_pageBlock.htm?search_text=pageblock



Table of Contents

Continue Reading

Related Posts

Industry Best Practices

Why Ignoring Industry Best Practices Could End Your Consulting Career

Learn why ignoring industry best practices in the consulting industry can have detrimental consequences for your career. From attending conferences and subscribing to industry journals to networking with peers and taking specialized courses, discover the essential steps to stay informed and relevant in your field. Don’t underestimate the importance of industry best practices – they could be the key to securing a successful and thriving consulting career.