readthedocs / sphinx_rtd_theme

Sphinx theme from Read the Docs
https://sphinx-rtd-theme.readthedocs.io/
MIT License
4.75k stars 1.73k forks source link

Hide/autohide navigation bar (similar to mobile behavior) #987

Open klieret opened 4 years ago

klieret commented 4 years ago

When writing tutorials in sphinx, we usually ask students to have the tutorial and the terminal side-by-side on their screen. However, the sidebar in sphinx is quite large and there's not much screen space left for the actual tutorial.

It would be really useful if the side bar would auto hide or could be hidden by the press of a button.

I know it's possible to hide it using something like


.wy-nav-side {
  display: none;
}

.wy-nav-content-wrap {
  margin-left: 0;
}

but it would be really nice to make have the option of toggling it.

mgaitan commented 3 years ago

as a vertical screen user, I also miss this feature. As you can see, a lot of the page is losing in a useless black space.

image

mgeier commented 3 years ago

It would of course be great to have this in the RTD theme, but until that happens, if you are seeking for an alternative theme in which you can hide the sidebar, you might have a look at my quite young theme https://insipid-sphinx-theme.readthedocs.io/. Most likely, there are a few other themes with such a feature.

felixvd commented 1 year ago

if you are seeking for an alternative theme in which you can hide the sidebar, you might have a look at my quite young theme https://insipid-sphinx-theme.readthedocs.io/

It looks like this theme has an option to hide the sidebar for certain pages, but it does not make the sidebar collapsible. A collapsible sidebar ("at the press of a button") is what this issue is proposing.

+1 to the proposal, by the way. And a ping to @hwayne from the connected issue who said that he could whip up a css to do this.

klieret commented 1 year ago

For anyone looking for another theme that supports this: https://sphinx-book-theme.readthedocs.io/en/stable/ has a button on the top (three horizontal lines). However, you have to click on it for every new page (that's fine for my use case, but probably not for people who want this feature because of vertical screens or other constraints)

mgeier commented 1 year ago

if you are seeking for an alternative theme in which you can hide the sidebar, you might have a look at my quite young theme https://insipid-sphinx-theme.readthedocs.io/

It looks like this theme has an option to hide the sidebar for certain pages, but it does not make the sidebar collapsible. A collapsible sidebar ("at the press of a button") is what this issue is proposing.

There is a button (consisting of three vertical lines) for that at the very top left (if that's not visible for you, please let me know!). On touch-enabled devices, the sidebar can be shown/hidden by swiping right/left. And there is also a keyboard shortcut m (for "menu") for that (in combination with Alt, Shift and/or Ctrl, depending on your browser, see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey).

The visible/hidden state is stored in your browser's LocalStorage, so it should stay the same when switching between pages of a subdomain (unless JavaScript is disabled).

felixvd commented 1 year ago

There is a button (consisting of three vertical lines) for that at the very top left

That works, in the same way as the one klieret just linked. I just didn't see it, my bad. The hamburger icon says "Click to see a menu" to me, I expected an arrow pointing left or similar for folding.

Thanks!

lola-masson commented 1 year ago

Any updates on this? Would still be very interested in a collapsible sidebar in the sphinx rtd theme :smile: