---
title: Tabs and anchors
description: Split a large site into top-level tabs, each with its own sidebar, and pin links to the top of the sidebar with anchors.
tag: Customization
readtime: 6 min read
---
> For AI agents: the complete documentation index is at [llms.txt](https://docs.docslit.com/0.3/llms.txt). This page as Markdown: [customization/tabs-and-anchors.md](https://docs.docslit.com/0.3/customization/tabs-and-anchors.md).


# 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](../writing-content/pages-and-navigation):

```json filename="docslit.json"
{
  "tabs": [
    {
      "tab": "Guides",
      "icon": "book-open",
      "sidebar": [
        { "group": "Start", "pages": ["index", "guides/install"] },
        { "group": "Operate", "pages": ["guides/deploy", "guides/webhooks"] }
      ]
    },
    {
      "tab": "Reference",
      "icon": "terminal",
      "sidebar": [
        { "group": "API", "pages": ["reference/api", "reference/cli"] }
      ]
    },
    { "tab": "Blog", "href": "https://example.com/blog" }
  ]
}
```

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`.

<wc-fields header="Tab options">
<wc-field name="tab" type="string" required>
The tab label. Aliases: `label`, `title`, `name`.
</wc-field>
<wc-field name="id" type="string">
A stable id for the tab. Defaults to a slug of the label. Use it in the `tab` frontmatter key.
</wc-field>
<wc-field name="icon" type="string">
An icon before the label. See [Icons](../components/icons).
</wc-field>
<wc-field name="tag" type="string">
A small badge shown next to the label, such as `New`.
</wc-field>
<wc-field name="sidebar" type="array | string">
The tab's sidebar groups, or `"auto"` to generate them from the folder in `path`, or from all of `docs/` when `path` is absent. See [Autogenerated sidebars](../writing-content/autogenerated-sidebars).
</wc-field>
<wc-field name="path" type="string">
A folder under `docs/` that belongs to the tab. It is the source for `"sidebar": "auto"`, and it decides the tab of pages that no tab lists.
</wc-field>
<wc-field name="landing" type="string">
The page id the tab opens. Defaults to the first visible page in its sidebar.
</wc-field>
<wc-field name="href" type="string">
Makes the tab a link to a URL, such as a blog on another domain. A link tab owns no pages and cannot have a sidebar. Add `target` to control how it opens.
</wc-field>
<wc-field name="hidden" type="boolean">
Keep the tab out of the tab bar. Its pages still work and still show their sidebar.
</wc-field>
<wc-field name="anchors" type="array">
Anchors that appear only while this tab is active. See [Anchors](#anchors).
</wc-field>
<wc-field name="openapi" type="boolean">
Marks the tab that holds the generated OpenAPI sidebar. If you use tabs and an OpenAPI spec but do not mark one, DocsLit adds an **API Reference** tab for those pages.
</wc-field>
<wc-field name="i18n" type="object">
Translated labels by locale, such as `{ "fr": "Guides" }`.
</wc-field>
</wc-fields>

### 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`:

```json filename="docslit.json"
{
  "tabs": [
    { "tab": "Guides", "path": "guides", "sidebar": "auto" },
    { "tab": "Reference", "path": "reference", "sidebar": "auto" }
  ]
}
```

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:

```yaml
---
title: Runbook
hidden: true
tab: Reference
---
```

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:

```json filename="docslit.json"
{
  "layout": {
    "tabsPlacement": "sidebar"
  }
}
```

<wc-fields header="Tab layout settings">
<wc-field name="layout.tabsPlacement" type="string" default="header">
`header` for a bar under the header, or `sidebar` for tabs at the top of the sidebar.
</wc-field>
<wc-field name="layout.tabsStyle" type="string" default="underline">
`underline` or `pill`. When set, it overrides a theme's own tab styling. See [Themes](theming#what-themes-change).
</wc-field>
<wc-field name="layout.tabsAlign" type="string" default="left">
`left` or `center`, for the header placement.
</wc-field>
</wc-fields>

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](design-tokens#layout-and-navigation-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.

```json filename="docslit.json"
{
  "anchors": [
    { "label": "Changelog", "href": "/changelog", "icon": "history", "tag": "New" },
    { "label": "Community", "href": "https://example.com/community", "icon": "fa-brands fa-discord" }
  ]
}
```

<wc-fields header="Anchor options">
<wc-field name="label" type="string" required>
The anchor text.
</wc-field>
<wc-field name="href" type="string" required>
A page path such as `/changelog`, or an external URL. External anchors open in a new tab.
</wc-field>
<wc-field name="icon" type="string">
An icon shown before the label.
</wc-field>
<wc-field name="tag" type="string">
A badge shown after the label.
</wc-field>
</wc-fields>

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:

```json filename="docslit.json"
{
  "tabs": [
    {
      "tab": "Guides",
      "anchors": [{ "label": "Changelog", "href": "/changelog", "icon": "history" }],
      "sidebar": [{ "group": "Start", "pages": ["index"] }]
    }
  ]
}
```

## 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](site-chrome)
- Control column widths and the table of contents in [Page layout](page-layout)
- Move a Mintlify or Fern navigation with [the importer](../migration/from-mintlify)
