Forum Discussion
smithme
Sep 21, 2021Copper 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?
5 Replies
Sort By
- shinypurpleCopper 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.
- smithmeCopper 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_FjllstrmCopper 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.