Skip to content
Discussion options

You must be logged in to vote

Hi @yangxuan74! If you use collapsed: true on each group it should only expand the group for the current page. However, once a user expands a group manually, Starlight respects that and will keep the group expanded on navigations until they collapse it manually again themselves. This ensures a more visually stable and less disorienting navigation experience.

If it is essential for you to collapse all groups even after user interaction, you could add a small client-side script to force them to close potentially:

<script>
document
	.querySelectorAll('.sidebar-content details:not(:has([aria-current="page"]))')
	.forEach((details) => {
		details.open = false;
	});
</script>

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by yangxuan74
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants