Skip to content
Eskais UI

Blocks

Docs Layout

DocsLayout, an app shell for documentation: a topbar slot, a sidebar that sticks under it at the full remaining height (a drawer on narrow screens), a breadcrumb slot above the page in the main column, the main landmark and a sticky table of contents. Also DocsToc (headings marked as you read with IntersectionObserver), DocsPager and DocsBreadcrumb.

Example

Installation

npx shadcn@latest add @eskais/docs-layout
npm packageslucide-react

Usage

Import
import { DocsToc, useTocItems } from "@/components/ui/docs-toc"import { DocsBreadcrumb, DocsLayout, DocsPager, DocsToc, useTocItems } from "@/components/ui/docs-layout"import { useActiveId, useTocItems } from "@/components/ui/use-docs-toc"

A documentation app shell: DocsLayout with a topbar (a Topbar with a SidebarTrigger), a sidebar that sticks under it, a breadcrumb header above the page, the content and a sticky toc; DocsToc from useTocItems, DocsPager and DocsBreadcrumb. useSidebarState({ storageKey }) wires the trigger and the Sidebar and remembers the collapsed state.

API reference

DocsToc

PropTypeDefault
itemsrequiredreadonly DocsTocItem[]–
titleA visible title above the list; the navigation is named by `aria-label` either way.ReactNode–
rootMarginWhere a heading counts as read, as an IntersectionObserver rootMargin; the top inset clears a sticky header.string"-96px 0px -60% 0px"

Also takes <nav> attributes except children.

DocsLayout

PropTypeDefault
topbarA Topbar across the top, usually with a SidebarTrigger in `leading`. The sidebar, the table of contents and anchor scrolling start below it (`--topbar-height`).ReactNode–
sidebarUsually a Sidebar with `trigger={false}` and the same controller as the topbar's SidebarTrigger. It sticks under the topbar at the full remaining height and scrolls on its own; on narrow screens it's the Sidebar's drawer.ReactNode–
tocUsually a DocsToc; sticky beside the content on extra-wide screens.ReactNode–
headerAbove the page in the main column, like a DocsBreadcrumb. It scrolls with the page.ReactNode–
mainIdThe `<main>` landmark's id, a SkipLink's target.string"main"
as`div` when the page already has its `<main>`, like a preview inside another page."main" | "div""main"

Also takes <div> attributes.

DocsPager

PropTypeDefault
previousDocsPagerLink–
nextDocsPagerLink–
labelsPartial<DocsPagerLabels>–

Also takes <nav> attributes except children.

DocsBreadcrumb

PropTypeDefault
itemsrequiredFrom the top level down; the last item is the current page. Give every other item an `href`, and `onFollow` to route on the client: an item without `href` renders as plain text that can't be followed.readonly DocsBreadcrumbItem[]–

Also takes Breadcrumb except children.

Other exports

useTocItemsuseActiveIdtype DocsTocItemtype DocsTocPropstype DocsBreadcrumbItemtype DocsBreadcrumbPropstype DocsLayoutPropstype DocsPagerLabelstype DocsPagerLinktype DocsPagerProps

Accessibility

  • The sidebar sticks under the topbar at the full remaining height and scrolls on its own; on narrow screens it is the Sidebar's drawer, opened by the same SidebarTrigger.
  • The SidebarTrigger is named for its next step (Collapse sidebar, Expand sidebar, Open navigation) and carries aria-expanded.
  • Everything in the page gets a scroll margin for the topbar, so anchors, focus and scrollIntoView never land under it.
  • DocsToc marks the heading being read with aria-current="location", from an IntersectionObserver.
  • Pass as="div" when the page already has its <main>.

Agent actions

Sidebar items, crumbs and pager links are Links: pass onFollow where agents should follow them. Agents collapse and expand the sidebar through the trigger or the Sidebar's own actions.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.