Custom Header and Sidebar
Replace the default docs header or sidebar with your own component, or remove either one entirely.
EmcyDocs now ships one docs layout. When you need different chrome, override the header or sidebar props instead of switching to another layout wrapper.
By default, DocsLayout provides:
import { DocsLayout } from "@emcy/docs";
export default function Layout({ children }) {
return (
<DocsLayout navigation={docsSource.getNavigation()}>
{children}
</DocsLayout>
);
}Pass header={null} when your product already owns the top chrome:
<DocsLayout navigation={docsSource.getNavigation()} header={null}>
{children}
</DocsLayout>Use a render prop when you want access to the current title or mobile navigation state:
<DocsLayout
navigation={docsSource.getNavigation()}
header={({ isMobile, currentTitle, toggleNavigation, isNavigationOpen }) => (
<div className={isMobile ? "my-mobile-header" : "my-desktop-header"}>
<strong>{isMobile ? currentTitle : "My product docs"}</strong>
{isMobile ? (
<button type="button" onClick={toggleNavigation}>
{isNavigationOpen ? "Close" : "Browse"}
</button>
) : null}
</div>
)}
>
{children}
</DocsLayout>If you want the default content frame but a custom navigation component, pass sidebar. If your product should not render a sidebar at all, pass sidebar={null}.
<DocsLayout
navigation={docsSource.getNavigation()}
sidebar={({ navigation, isMobile, closeNavigation }) => (
<MySidebar
items={navigation}
compact={isMobile}
onNavigate={closeNavigation}
/>
)}
>
{children}
</DocsLayout>