Improve spacing in sidebar section headings

This tries to improve the spacing between section headings in the
sidebar so that they don't blend together. This is particularly a
problem with long headings that word wrap. This just tightens up the
spacing when it wraps, and increases the spacing between the sections.

I still don't 100% like how the distinction between sections can be
difficult to see. My original prototype had other indicators like
bullets, but those ended up not working too well. This might still need
some work in the future.

Fixes https://github.com/rust-lang/mdBook/issues/3085
This commit is contained in:
Eric Huss 2026-05-19 15:19:29 -07:00
parent 4f5b48792f
commit 5a946ae676

View file

@ -624,6 +624,15 @@ html:not(.js) .sidebar-resize-handle {
margin-block-start: 0.6em;
}
.chapter li.header-item {
/* Make sure there is plenty of spacing between sections so they don't blend in
with each other. */
margin-block-end: 0.5em;
/* Avoid too much spacing between lines when section heading word wraps so that
it can be distinguished between successive headings. */
line-height: 1.5em;
}
/* When expanded, rotate the chevron to point down. */
.chapter li.expanded > span > .chapter-fold-toggle div {
transform: rotate(90deg);