Forum Discussion
smithme
Sep 21, 2021Brass Contributor
HOW TO: Hide web part when it's empty
I have a web part I wrote that I want to hide when there is no content in it (like the News web part). How do I do that?
shinypurple
Sep 22, 2021Copper Contributor
smithme There's usually an option to hide the web part if there's nothing to show. It's definitely on 'News', although maybe not on every web part.
- smithmeSep 22, 2021Brass ContributorSorry, I wasn't more clear. I am writing a custom webpart. I want it to take up zero vertical space on the page when it is empty. How do I programmatically, tell my webpart to display:none;
- Fredrik_FjllstrmJan 22, 2024Copper ContributorI would add a CSS class of hidden that only has display:none and add that class to whatever element I want to hide if the webpart is empty.
- mcadsFeb 15, 2024Copper Contributor
Fredrik_Fjllstrm Can you post an example of how to do this? I'm having the same issue.
Thanks so much!