SOLVED

IS it Possible to remove the left hand nav from a modern team site

Iron Contributor

Hi

 

Is it possible to remove the left hand navigation bar from a modern team site so that If I use a Hero Web Part it can take up the whole of the screen ?

 

Then can I put the old search box in the top right hand corner of the screen and point it to a classical Search Results page where I have refiners etc ?

 

Thanks

 

Nigel

17 Replies
best response confirmed by Nigel Price (Iron Contributor)
Solution

I think the supported way to do this would be to write an extension (so it is applied to all pages in the site) that implements CSS to make the changes you are after.

 

The CSS to hide the left hand nav on a modern page is:

 
nav[role='navigation'] {
    display: none !important;
}
div[class^='searchBox_'] {
    display: none !important;
}
div[class^='pageContainer_'] {
    left: 0 !important;
} 

 

The same extension that injects this CSS could also display a search box (if you want it on every page), that redirects users to your search results page and injects the query into the 'k' querystring parameter

 

hope it helps,

 

Nigel

 

Thanks Nigel - it certainly does.

Thanks Nigel, that's what I am trying to do from the extension.

Did you notice a that left nav is still rendered for a split second before our application customizer actually loads?

Hey,

 

mine is actually running from a web part on the page (not a customizer) and yes it definitely shows the LHS nav for a flicker before the CSS is processed.

 

There may be a better way to get the CSS processed earlier in the page load, but I am not sure how/what is the best way to achieve that - sorry.

 

If you do find out, please post the solution on this thread as it would be good to know

 

Thanks

 

Nigel

I found the answer without using any stylesheets.  Under Site Settings -> change the look, then select the current look, ten on the next page change the Site Layout to Oslo.

 

sitelayout.jpg

@Chad Renstromwhat kind of site are you doing that on? when i try it on a modern group enabled team site, it does not work on the home page.

Yes, It can be done. Go to Site Settings -> Navigation Elements (under Look and Feel).

Uncheck "Enable Quick launch". This should remove the left navigation pane.

How are you doing this from a web part on a modern page?  

Sometimes the simplest solutions are always the last to be suggested, thanks for that!

In modern pages you can do this without css - just in site settings, Navigation Elements -> uncheck Quick launch

@Angus Muir  That doesn't seem to work, at least now in my modern site.

@Nigel Price I found that you can hide the div in a CSS stylesheet. Just replace the red text below with the id for your div and it should hide it. I've noticed that the div changes after a while which means I need to go update the id for that div but it works well otherwise.

 

div.spNav_1846ed68 {position: absolute; visibility: hidden; display: none !important;}
 
 

@dancourcelles I was building personal pages for employees that don't require LHS navigation and was able to remove it from "Site Settings" -->"Navigation" --> "Structural Navigation: Editing and Sorting".  Select "Current Navigation" and delete all items in the list.  Click OK.  As a note, this removed the navigation, but you can't use the column space that was vacated by the navigation.  So even with a 4 column layout (3 columns plus the vertical column), the columns just float left and the (now empty and unusable) fifth column floats to the right hand side of the page.

@PCH_Mark 

When I remove left hand navigation my search box disappears. When I refresh screen it flickers for less then a second and boom--gone.

How do I get it back, I need search box.

@Nigel Price 

 

The best way is to delete all left side navigation links then reload the page, quick launch disappears. It works.

 

Best Regards,

G Vijai Kumar

This is the only solution that worked for me in a SharePoint modern team site.
1 best response

Accepted Solutions
best response confirmed by Nigel Price (Iron Contributor)
Solution

I think the supported way to do this would be to write an extension (so it is applied to all pages in the site) that implements CSS to make the changes you are after.

 

The CSS to hide the left hand nav on a modern page is:

 
nav[role='navigation'] {
    display: none !important;
}
div[class^='searchBox_'] {
    display: none !important;
}
div[class^='pageContainer_'] {
    left: 0 !important;
} 

 

The same extension that injects this CSS could also display a search box (if you want it on every page), that redirects users to your search results page and injects the query into the 'k' querystring parameter

 

hope it helps,

 

Nigel

 

View solution in original post