Does anyone know how I can access the standard CSS styling that SFDC uses for a record's edit page? I used pageBlock, pageBlockSection,a dn pageBlockSectionItem tags to mimic the styling, but I'm running into limitations in other areas that require me to now use HTML tables. I'd like to create those tables to mimic the same CSS styling. Any ideas? Thanks.
1 Answer
This is a tough path to go down. The best case would be to use apex elements. That being said, there are tons of use cases where you just need to write your own HTML. While it is more work, my suggestion would be to create your own stylesheet that mimics Salesforce styling. Trying to directly access their styles leaves you very prone down the road as Salesforce updates its styles. There are a number of other advantages to creating your own stylesheet for the pages:
- You can take the parts of Salesforce styling that you like, but tweak elements that you do not.
- If you are having to write your own HTML, it is probably the case that there is not a direct translation from the Salesforce styles to your use case. This gives you an option to tailor the page for your end users.
- You can easily tweak styles as you get feedback from your end users.
- Use LESS or SASS to create your stylesheet and maintaining it becomes a breeze.
-
Thanks. I actually am trying to re-create their styles using my own. The trouble I am having to determining their elements. I'm using the Chrome inspect elements, but it's rather tedious. I was hoping there was a central repository somewhere that I could mimic as necessary. Commented Nov 19, 2015 at 19:35
-
In my opinion, the HTML generated by many apex tags like pageBlock is pretty rough (they love their nested tables). CSS is so incredibly flexible that I think your best bet is to make the best HTML for your use case, then style it up. Depending on the browsers you need to support, using a more modern layout like flexbox (developer.mozilla.org/en-US/docs/Web/CSS/…) becomes a good option. Commented Nov 19, 2015 at 19:45