Tabs and anchors
A single sidebar works for a small site. When your docs have distinct sections, such as guides, an API reference and a blog, tabs give each section its own sidebar. Anchors pin a few important links, such as a changelog or a community chat, to the top of the sidebar.
Tabs
Add a tabs array to docslit.json. Each tab has a name, an optional icon and its own sidebar, which uses the same groups as the top-level sidebar:
The active tab follows the page the reader is on, so the sidebar always shows the right section. When tabs is set, the top-level sidebar is ignored, and docslit validate tells you with tabs-sidebar-ignored.
label, title, name.tab frontmatter key.New."auto" to generate them from the folder in path, or from all of docs/ when path is absent. See Autogenerated sidebars.docs/ that belongs to the tab. It is the source for "sidebar": "auto", and it decides the tab of pages that no tab lists.target to control how it opens.{ "fr": "Guides" }.Generate a tab from a folder
A tab with a path and "sidebar": "auto" builds its sidebar from the folder, so new pages appear without editing docslit.json:
A tab with only a path still claims the pages in that folder that no tab lists.
Place a page in a tab
A page belongs to the tab that lists it in its sidebar. Hidden pages and pages that no tab lists use the tab frontmatter key, naming the tab by label or id:
Without tab, an unlisted page joins the tab whose path covers it, and otherwise the first tab.
Where tabs appear
By default tabs sit in a bar under the header. Set layout.tabsPlacement to "sidebar" to put them at the top of the sidebar instead, which saves vertical space:
header for a bar under the header, or sidebar for tabs at the top of the sidebar.underline or pill. When set, it overrides a theme's own tab styling. See Themes.left or center, for the header placement.On screens narrower than 1024 pixels the tab bar is hidden, and the tabs and the navbar links move into the navigation drawer, so every section stays reachable on a phone.
Tabs are styled with the --tab-* tokens, so you can change their spacing, colors and indicator in your own stylesheet.
Anchors
An anchor is a pinned link at the top of the sidebar, above the page groups. It is a good fit for destinations that are not part of the page tree.
/changelog, or an external URL. External anchors open in a new tab.Anchors in the top-level anchors array show in every sidebar. A tab can have its own anchors array, whose entries show only while that tab is active:
Check your navigation
docslit validate checks tabs and anchors. It reports an error for an unusable tabs array (tabs-invalid) and warns about a duplicate tab name (tab-duplicate-name), a page listed in two tabs (tab-duplicate-page), an empty tab (tab-empty), a missing landing page or path folder (tab-landing-missing, tab-path-missing), a link tab that also has pages (tab-href-with-pages), a bad anchor (anchor-invalid) and a frontmatter tab that matches no tab (frontmatter-unknown-tab).
Next steps
- Add links, buttons and a GitHub star count to the header in Site chrome
- Control column widths and the table of contents in Page layout
- Move a Mintlify or Fern navigation with the importer