Sidebar Links
Customise sidebar navigation links on Docs Layout.
Overview

Sidebar items are rendered from the page tree you passed to <DocsLayout />.
For source.pageTree, it generates the tree from your file structure, see available patterns.
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
import { source } from '@/lib/source';
import type { ReactNode } from 'react';
export default function Layout({ children }: { children: ReactNode }) {
  return (
    <DocsLayout
      tree={source.pageTree}
      // other props
    >
      {children}
    </DocsLayout>
  );
}You may hardcode it too:
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
import type { ReactNode } from 'react';
export default function Layout({ children }: { children: ReactNode }) {
  return (
    <DocsLayout
      tree={{
        name: 'docs',
        children: [],
      }}
      // other props
    >
      {children}
    </DocsLayout>
  );
}Sidebar Tabs (Dropdown)
Sidebar Tabs are folders with tab-like behaviours, only the content of opened tab will be visible.

By default, the tab trigger will be displayed as a Dropdown component (hidden unless one of its items is active).
You can add items by marking folders as Root Folders, create a meta.json file in the folder:
{
  "title": "Name of Folder",
  "description": "The description of root folder (optional)",
  "root": true
}Or specify them explicitly:
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
<DocsLayout
  sidebar={{
    tabs: [
      {
        title: 'Components',
        description: 'Hello World!',
        // active for `/docs/components` and sub routes like `/docs/components/button`
        url: '/docs/components',
        // optionally, you can specify a set of urls which activates the item
        // urls: new Set(['/docs/test', '/docs/components']),
      },
    ],
  }}
/>;Set it to false to disable:
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
<DocsLayout sidebar={{ tabs: false }} />;Want further customisations?
You can specify a banner to the Docs Layout component.
import { DocsLayout, type DocsLayoutProps } from 'fumadocs-ui/layouts/docs';
import type { ReactNode } from 'react';
import { baseOptions } from '@/lib/layout.shared';
import { source } from '@/lib/source';
const docsOptions: DocsLayoutProps = {
  ...baseOptions(),
  tree: source.pageTree,
  sidebar: {
    banner: <div>Hello World</div>,
  },
};
export default function Layout({ children }: { children: ReactNode }) {
  return <DocsLayout {...docsOptions}>{children}</DocsLayout>;
}Decoration
Change the icon/styles of tabs.
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
<DocsLayout
  sidebar={{
    tabs: {
      transform: (option, node) => ({
        ...option,
        icon: <MyIcon />,
      }),
    },
  }}
/>;How is this guide?
Last updated on
