Core layout components that provide the fundamental page structure, theme context, and responsive design framework for Docusaurus sites.
The primary layout wrapper component that structures the entire page layout.
/**
* Main page layout wrapper component
* @param props - Layout configuration props
* @returns Layout structure with header, main content, and footer
*/
function Layout(props: LayoutProps): ReactNode;
interface LayoutProps {
readonly children?: ReactNode;
readonly noFooter?: boolean;
readonly wrapperClassName?: string;
// SEO and metadata props
readonly title?: string;
readonly description?: string;
}Usage Example:
import Layout from '@theme/Layout';
export default function MyPage() {
return (
<Layout
title="My Custom Page"
description="Description for SEO"
wrapperClassName="my-custom-wrapper"
>
<div>
<h1>My Page Content</h1>
<p>This content will be wrapped with header and footer.</p>
</div>
</Layout>
);
}Context provider that supplies theme state and configuration to all child components.
/**
* Layout context provider for theme state management
* @param props - Provider props containing children
* @returns Context provider wrapper
*/
function LayoutProvider(props: LayoutProviderProps): ReactNode;
interface LayoutProviderProps {
readonly children: ReactNode;
}Accessibility component providing keyboard navigation skip link.
/**
* Accessibility skip-to-content link for keyboard navigation
* @returns Skip link that appears on focus
*/
function SkipToContent(): ReactNode;Floating action button for scrolling back to page top.
/**
* Back to top button that appears when scrolling down
* @returns Floating button for scroll-to-top functionality
*/
function BackToTopButton(): ReactNode;Site-wide announcement banner that appears at the top of pages.
/**
* Site-wide announcement bar component
* @returns Announcement banner or null if not configured
*/
function AnnouncementBar(): ReactNode | null;Content wrapper for announcement bar text and styling.
/**
* Announcement bar content wrapper
* @param props - Content container props
* @returns Styled content container
*/
function AnnouncementBarContent(props: AnnouncementBarContentProps): ReactNode;
interface AnnouncementBarContentProps extends ComponentProps<'div'> {}Close button for dismissible announcement bars.
/**
* Close button for announcement bar
* @param props - Button props
* @returns Close button element
*/
function AnnouncementBarCloseButton(props: AnnouncementBarCloseButtonProps): ReactNode;
interface AnnouncementBarCloseButtonProps extends ComponentProps<'button'> {}Root theme context provider managing color mode and theme state.
/**
* Root theme context provider
* @param props - Provider props
* @returns Theme context wrapper
*/
function ThemeProvider(props: ThemeProviderProps): ReactNode;
interface ThemeProviderProps {
readonly children: ReactNode;
}Theme-aware page title formatting component.
/**
* Theme-aware page title formatter
* @param props - Title formatter props
* @returns Formatted title element
*/
function ThemeProviderTitleFormatter(props: TitleFormatterProps): ReactNode;
interface TitleFormatterProps {
readonly children: ReactNode;
}Component for switching between light and dark themes.
/**
* Color mode toggle switch for dark/light theme
* @param props - Toggle configuration props
* @returns Theme toggle button
*/
function ColorModeToggle(props: ColorModeToggleProps): ReactNode;
interface ColorModeToggleProps {
readonly className?: string;
readonly buttonClassName?: string;
readonly respectPrefersColorScheme: boolean;
readonly value: ColorMode | null;
readonly onChange: (colorMode: ColorMode | null) => void;
}
type ColorMode = 'light' | 'dark';Usage Example:
import { useColorMode } from '@docusaurus/theme-common';
import ColorModeToggle from '@theme/ColorModeToggle';
export default function CustomToggle() {
const { colorMode, setColorMode } = useColorMode();
return (
<ColorModeToggle
className="custom-toggle"
value={colorMode}
onChange={setColorMode}
respectPrefersColorScheme={true}
/>
);
}Site logo component with theme-aware image support.
/**
* Site logo component with theme-aware images
* @param props - Logo configuration props
* @returns Logo link with image
*/
function Logo(props: LogoProps): ReactNode;
interface LogoProps extends ComponentProps<'a'> {
readonly imageClassName?: string;
readonly titleClassName?: string;
}Image component that switches between light and dark mode variants.
/**
* Theme-aware image component
* @param props - Image props with light/dark variants
* @returns Image element that responds to theme changes
*/
function ThemedImage(props: ThemedImageProps): ReactNode;
interface ThemedImageProps extends Omit<ComponentProps<'img'>, 'src'> {
readonly sources: {
readonly light: string;
readonly dark: string;
};
}Usage Example:
import ThemedImage from '@theme/ThemedImage';
export default function MyComponent() {
return (
<ThemedImage
alt="My Image"
sources={{
light: '/img/logo-light.png',
dark: '/img/logo-dark.png',
}}
width="200"
height="100"
/>
);
}Components for handling draft and unlisted content visibility.
/**
* Content visibility wrapper for draft/unlisted content
* @param props - Visibility metadata props
* @returns Visibility wrapper component
*/
function ContentVisibility(props: ContentVisibilityProps): ReactNode;
interface ContentVisibilityProps {
readonly metadata: {
readonly unlisted: boolean;
readonly frontMatter: {
draft?: boolean;
unlisted?: boolean;
};
};
}Visual indicator for draft content.
/**
* Draft content marker component
* @param props - Draft marker props
* @returns Draft indicator element
*/
function Draft(props: DraftProps): ReactNode;
interface DraftProps {
className?: string;
}Visual indicator for unlisted content.
/**
* Unlisted content marker component
* @param props - Unlisted marker props
* @returns Unlisted indicator element
*/
function Unlisted(props: UnlistedProps): ReactNode;
interface UnlistedProps {
className?: string;
}Component for injecting search-specific metadata.
/**
* Search metadata component for SEO and search indexing
* @param props - Search metadata props
* @returns Meta tags for search optimization
*/
function SearchMetadata(props: SearchMetadataProps): ReactNode;
interface SearchMetadataProps {
readonly locale?: string;
readonly version?: string;
readonly tag?: string;
}Component for site-wide metadata and SEO tags.
/**
* Site metadata component for global SEO
* @returns Meta tags for site-wide SEO
*/
function SiteMetadata(): ReactNode;The layout components work together in a hierarchical structure:
This hierarchy ensures proper theme context propagation and consistent layout behavior across all pages.
import React from 'react';
import Layout from '@theme/Layout';
import LayoutProvider from '@theme/Layout/Provider';
export default function CustomPage() {
return (
<Layout
title="Custom Page"
description="A custom page with layout components"
noFooter={false}
wrapperClassName="custom-page"
>
<div className="container">
<h1>Custom Page Content</h1>
<p>This page uses the standard Docusaurus layout.</p>
</div>
</Layout>
);
}import React from 'react';
import OriginalLayout from '@theme-original/Layout';
import { useThemeConfig } from '@docusaurus/theme-common';
export default function CustomLayout(props) {
const {
navbar: {hideOnScroll = false},
} = useThemeConfig();
return (
<div className={hideOnScroll ? 'navbar-hide-on-scroll' : ''}>
<OriginalLayout {...props} />
</div>
);
}