LogoMkSaaS Docs
    LogoMkSaaS Docs
    Homepage

    Introduction

    Quick StartWhat is FumadocsComparisons

    Setup

    Manual InstallationStatic Export

    Writing

    MarkdownInternationalization

    UI

    OverviewThemesSearch
    Components
    MDX
    Docs LayoutHome LayoutNotebookDocs PageRoot Provider
    X (Twitter)
    Layouts

    Docs Layout

    The layout of documentation

    The layout of documentation pages, it includes a sidebar and mobile-only navbar.

    It is a server component, you should not reference it in a client component.

    Usage

    Pass your page tree to the component.

    layout.tsx
    import { DocsLayout } from 'fumadocs-ui/layouts/docs';
    import { baseOptions } from '@/app/layout.config';
    import type { ReactNode } from 'react';
    
    export default function Layout({ children }: { children: ReactNode }) {
      return (
        <DocsLayout {...baseOptions} tree={tree}>
          {children}
        </DocsLayout>
      );
    }

    Sidebar

    layout.tsx
    import { DocsLayout } from 'fumadocs-ui/layouts/docs';
    
    <DocsLayout
      sidebar={{
        // sidebar options:
        enabled: true,
      }}
    />;

    Sidebar Tabs

    See Navigation Guide for usages.

    Decoration

    Change the icon/styles of tabs.

    import { DocsLayout } from 'fumadocs-ui/layouts/docs';
    
    <DocsLayout
      sidebar={{
        tabs: {
          transform: (option, node) => ({
            ...option,
            icon: 'my icon',
          }),
        },
      }}
    />;

    Nav

    A mobile-only navbar, we recommend to customise it from baseOptions.

    Docs Navigation Preview

    import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
    
    export const baseOptions: BaseLayoutProps = {
      githubUrl: 'https://github.com/fuma-nama/fumadocs',
      nav: {
        title: 'My App',
      },
    };

    Transparent Mode

    To make the navbar background transparent, you can configure transparent mode.

    import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
    
    export const baseOptions: BaseLayoutProps = {
      nav: {
        transparentMode: 'top',
      },
    };
    ModeDescription
    alwaysAlways use a transparent background
    topWhen at the top of page
    noneDisable transparent background (default)

    Replace Navbar

    To replace the navbar in Docs Layout, set nav.component to your own component.

    layout.tsx
    import { baseOptions } from '@/app/layout.config';
    import { DocsLayout } from 'fumadocs-ui/layouts/notebook';
    import type { ReactNode } from 'react';
    
    export default function Layout({ children }: { children: ReactNode }) {
      return (
        <DocsLayout
          {...baseOptions}
          nav={{
            component: <CustomNavbar />,
          }}
        >
          {children}
        </DocsLayout>
      );
    }

    Fumadocs uses CSS Variables to share the size of layout components, and fit each layout component into appropriate position.

    You need to override --fd-nav-height to the exact height of your custom navbar, this can be done with a CSS stylesheet (e.g. in global.css):

    :root {
      --fd-nav-height: 80px !important;
    }

    Advanced

    Disable Prefetching

    By default, it uses the Next.js Link component with prefetch enabled. When the link component appears into the browser viewport, the content (RSC payload) will be prefetched.

    On Vercel, this may cause a high usage of serverless functions and Data Cache. It can also hit the limits of some other hosting platforms.

    You can disable prefetching to reduce the amount of RSC requests.

    import { DocsLayout } from 'fumadocs-ui/layouts/docs';
    
    <DocsLayout sidebar={{ prefetch: false }} />;

    Heading

    Heading components for your MDX documentation

    Home Layout

    Shared layout for other pages

    Table of Contents

    Usage
    Sidebar
    Sidebar Tabs
    Decoration
    Nav
    Transparent Mode
    Replace Navbar
    Advanced
    Disable Prefetching