{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stacked-layout",
  "title": "StackedLayout",
  "description": "The shell of an app with a `Navbar`: the bar across the top, in view while the page scrolls, an optional `toolbar` under it for the page's own tools, and the page below them in a centered column.",
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/sidebar/stacked-layout.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useId, useRef, useState, type JSX, type ReactNode, type Ref, type RefObject } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/** Props for {@link StackedLayout}. */\nexport interface StackedLayoutProps {\n  /** The app's `Navbar`. It stays at the top while the page scrolls, unless `navbarBehavior` says otherwise. */\n  navbar: ReactNode;\n  /**\n   * A second bar right under the navbar, for the page's own tools: a search field, a view\n   * switcher, a week stepper. Usually a `Toolbar`. It runs the full width with the navbar's\n   * padding and its own line below, fills the bar's width (wrap several things in one element\n   * to put them in a row), and moves with the navbar: it sticks, scrolls away or hides with it.\n   * It is a landmark named `toolbarLabel`, so a screen-reader user can jump to it.\n   */\n  toolbar?: ReactNode;\n  /** Names the toolbar's landmark for screen readers. It is not shown. @default \"Page tools\" */\n  toolbarLabel?: string | undefined;\n  /**\n   * What the navbar, and the toolbar under it, do while the page scrolls. `\"sticky\"` keeps them\n   * at the top. `\"static\"` lets them scroll away with the page, for a document. `\"auto-hide\"` is\n   * for a reading surface with art that runs under the bars: they slide up out of view as the\n   * reader scrolls down, and come back on a scroll up, at the top of the page, or when keyboard\n   * focus moves into them. Keyboard focus or an open menu in them holds them in view. Over the\n   * page they are translucent, with the page blurred behind them. With reduced motion they show\n   * and hide at once, without sliding.\n   * @claim \"Keyboard focus or an open menu in them\" registry/ouro/components/ouro/sidebar/stacked-layout.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/stacked-layout.test.tsx::StackedLayout with navbarBehavior auto-hide > stays in view while keyboard focus is in it, and comes back when focus moves into it)\n   * @claim \"Keyboard focus or an open menu in them\" registry/ouro/components/ouro/sidebar/stacked-layout.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/stacked-layout.test.tsx::StackedLayout with navbarBehavior auto-hide > stays in view while a menu opened from it is open)\n   * @default \"sticky\"\n   */\n  navbarBehavior?: \"sticky\" | \"static\" | \"auto-hide\" | (string & { 'default is \"sticky\"; use \"sticky\", \"static\" or \"auto-hide\"': never }) | undefined;\n  /**\n   * The page. It renders inside the page's `<main>`, in a centered column up to 72rem wide.\n   *\n   * @claim \"It renders inside the page's `<main>`\" registry/ouro/components/ouro/sidebar/stacked-layout.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/stacked-layout.test.tsx::StackedLayout > centers the page in a column of readable width, and runs edge to edge with bleed)\n   * @claim \"It renders inside the page's `<main>`\" registry/ouro/components/ouro/sidebar/stacked-layout.tsx verify:fileLine(registry/ouro/components/ouro/sidebar/stacked-layout.tsx, /mx-auto\\smax-w-6xl/)\n   * @claim \"It renders inside the page's `<main>`\" https://tailwindcss.com/docs/max-width verify:urlOk(https://tailwindcss.com/docs/max-width)\n   */\n  children: ReactNode;\n  /**\n   * The element around the page. Pass `\"div\"` when the layout renders inside a page that\n   * already has a `<main>`, since a document has one.\n   * @default \"main\"\n   */\n  as?: \"main\" | \"div\" | undefined;\n  /** A line at the bottom of the page: links, a copyright. It sits at the bottom of the screen on a short page. */\n  footer?: ReactNode;\n  /** Removes the column and its padding, for content that runs edge to edge (a map, a cover photo). */\n  bleed?: boolean | undefined;\n  /** The text of the link that skips the navbar, shown when it has keyboard focus. @default \"Skip to content\" */\n  skipLabel?: string | undefined;\n  /** Layout only: height and margins (`min-h-96`). Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. A `Navbar` opens its own drawer on a phone; for a sidebar use `SidebarLayout`. */\n  sidebar?: { \"Use <StackedLayout navbar={<Navbar ... />}>, or <SidebarLayout sidebar={...}>\": never };\n  /** Not a prop. Ouro UI uses `navbar`: `<StackedLayout navbar={<Navbar … />}>`. */\n  header?: { \"Use <StackedLayout navbar={<Navbar ... />}>\": never };\n  /** Not a prop. Use `navbarBehavior=\"auto-hide\"`. */\n  hideOnScroll?: { 'Use <StackedLayout navbarBehavior=\"auto-hide\">': never };\n  /** Not a prop. The navbar sticks by default; `navbarBehavior=\"static\"` lets it scroll away. */\n  sticky?: { 'Use <StackedLayout navbarBehavior=\"static\"> to let the navbar scroll away': never };\n}\n\n// Class strings are literal so the app's Tailwind finds them when it compiles.\n\n// The first tab stop: hidden until it has keyboard focus, then shown at the top corner. Its size is\n// set in rem whether or not it has focus, so a hidden link never inherits a px size from its page.\nconst skipClass =\n  \"sr-only text-base leading-5 focus-visible:top-2 focus-visible:start-2 focus-visible:z-20 focus-visible:m-0 focus-visible:size-auto \" +\n  \"focus-visible:overflow-visible focus-visible:[clip-path:none] focus-visible:px-4 focus-visible:py-2.5 focus-visible:whitespace-nowrap \" +\n  \"focus-visible:rounded-ouro-lg focus-visible:bg-background focus-visible:text-foreground focus-visible:font-medium \" +\n  \"focus-visible:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid\";\n\n// The navbar and the toolbar: sticky, or with auto-hide, translucent over the page and solid\n// where the reader asks for less transparency or more contrast. Static needs no class.\nconst stickyClass = \"sticky top-0 z-10\";\nconst autoHideClass =\n  \"sticky top-0 z-10 bg-background/80 backdrop-blur-md [&>[data-ouro=navbar]]:bg-transparent \" +\n  \"transition-[translate] duration-(--ouro-duration-base) ease-(--ouro-ease-out) data-closed:-translate-y-full motion-reduce:transition-none \" +\n  \"[@media(prefers-reduced-transparency:reduce)]:bg-background [@media(prefers-reduced-transparency:reduce)]:backdrop-blur-none \" +\n  \"contrast-more:bg-background contrast-more:backdrop-blur-none\";\n\n// The toolbar's bar: full width, with the Navbar's padding and safe-area insets and its own line below.\nconst toolbarClass =\n  \"box-border flex min-h-12 flex-col justify-center border-0 border-b border-solid border-border py-1.5 \" +\n  \"ps-[max(1rem,env(safe-area-inset-left,0px))] pe-[max(1rem,env(safe-area-inset-right,0px))]\";\n\n/**\n * With `auto-hide`: whether the bars are out of view. A scroll down past them hides them,\n * unless keyboard focus or an open menu is in them; any scroll up, or the top of the page, shows them.\n */\nfunction useAutoHide(enabled: boolean, bars: RefObject<HTMLDivElement | null>): [hidden: boolean, show: () => void] {\n  const [hidden, setHidden] = useState(false);\n  useEffect(() => {\n    if (!enabled) return;\n    const region = bars.current!;\n    let last = scrollY;\n    const onScroll = () => {\n      const [y, previous] = [scrollY, last];\n      last = y;\n      if (y < previous || y <= region.offsetHeight) setHidden(false);\n      else if (y > previous && region.querySelector(\":focus-visible, [aria-expanded=true]\") === null) setHidden(true);\n    };\n    addEventListener(\"scroll\", onScroll);\n    return () => {\n      removeEventListener(\"scroll\", onScroll);\n      // So `hidden` is only ever true while auto-hide is on.\n      setHidden(false);\n    };\n  }, [enabled, bars]);\n  return [hidden, () => setHidden(false)];\n}\n\n/**\n * The shell of an app with a `Navbar`: the bar across the top, in view while the page\n * scrolls, an optional `toolbar` under it for the page's own tools, and the page below them\n * in a centered column. It renders the page's `<main>`, starts with a \"Skip to content\" link,\n * and keeps its footer at the bottom of a short page. `navbarBehavior` lets the bars scroll\n * away with a document, or slide out of the way of a reading surface.\n *\n * The phone menu opens once JavaScript has loaded (after hydration);\n * the links are in the server HTML from 640px up.\n *\n * Use `SidebarLayout` instead when the navigation is a `Sidebar`. Use `AuthLayout` for the\n * sign-in pages.\n *\n * @group Navigation\n * @see https://ui.ouroboros.bot/docs/stacked-layout\n *\n * @example\n * <StackedLayout\n *   navbar={<Navbar label=\"Main\" items={items} currentPath={pathname} />}\n *   toolbar={<Toolbar label=\"Week\" items={weekTools} />}\n * >\n *   <Outlet />\n * </StackedLayout>\n * @claim \"The phone menu opens once JavaScript\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > puts the nav and its links in the server HTML)\n * @claim \"The phone menu opens once JavaScript\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > becomes a menu button that opens a drawer below 640px)\n */\nexport function StackedLayout(props: StackedLayoutProps): JSX.Element {\n  const {\n    navbar,\n    toolbar,\n    toolbarLabel = \"Page tools\",\n    navbarBehavior = \"sticky\",\n    children,\n    as,\n    footer,\n    bleed,\n    skipLabel = \"Skip to content\",\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    sidebar,\n    header,\n    hideOnScroll,\n    sticky,\n  } = props;\n  const behavior = navbarBehavior === \"static\" || navbarBehavior === \"auto-hide\" ? navbarBehavior : \"sticky\";\n  useAppearanceClassNameCheck(\n    \"StackedLayout\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; StackedLayout sets its own look`\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"StackedLayout\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          navbar === undefined && [\"navbar is required\", '<StackedLayout navbar={<Navbar label=\"Main\" items={[…]} />}>'],\n          sidebar !== undefined && [\n            \"sidebar is not a prop; Navbar opens its own drawer on a phone\",\n            \"<StackedLayout navbar={<Navbar … />}>, or <SidebarLayout sidebar={<Sidebar … />}> for a sidebar\",\n          ],\n          header !== undefined && [\"header is not a prop\", \"<StackedLayout navbar={<Navbar … />}>\"],\n          behavior !== navbarBehavior && [`navbarBehavior=\"${navbarBehavior}\" is not a behavior`, '<StackedLayout navbarBehavior=\"sticky\">'],\n          hideOnScroll !== undefined && [\"hideOnScroll is not a prop\", '<StackedLayout navbarBehavior=\"auto-hide\">'],\n          sticky !== undefined && [\"sticky is not a prop; the navbar sticks by default\", '<StackedLayout navbarBehavior=\"static\"> to let it scroll away'],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  const mainId = useId();\n  const Page = as === \"div\" ? \"div\" : \"main\";\n  // The link's address moves focus by itself in most browsers; the handler makes it certain.\n  const main = useRef<HTMLDivElement>(null);\n  const bars = useRef<HTMLDivElement>(null);\n  const autoHide = behavior === \"auto-hide\";\n  const [hidden, show] = useAutoHide(autoHide, bars);\n  return (\n    <div ref={ref} data-ouro=\"stacked-layout\" className={cn(\"relative flex min-h-dvh flex-col bg-background text-foreground\", className)}>\n      <a\n        href={`#${mainId}`}\n        data-ouro-control=\"stacked-layout\"\n        data-ouro-part=\"skip-link\"\n        // Stryker disable next-line ArrowFunction: the link's address also moves focus, so an empty handler changes nothing a test can see.\n        onClick={() => main.current!.focus()}\n        className={skipClass}\n      >\n        {skipLabel}\n      </a>\n      <div\n        ref={bars}\n        data-ouro-stacked-layout-navbar=\"\"\n        data-ouro-part=\"bars\"\n        data-behavior={behavior}\n        data-open={autoHide && !hidden ? \"\" : undefined}\n        data-closed={hidden ? \"\" : undefined}\n        onFocus={show}\n        className={autoHide ? autoHideClass : behavior === \"sticky\" ? stickyClass : undefined}\n      >\n        {navbar}\n        {toolbar !== undefined && (\n          <section aria-label={toolbarLabel} data-ouro-stacked-layout-toolbar=\"\" className={cn(toolbarClass, !autoHide && \"bg-background\")}>\n            {toolbar}\n          </section>\n        )}\n      </div>\n      <Page ref={main} id={mainId} tabIndex={-1} className={cn(\"box-border w-full min-w-0 flex-1 outline-none\", !bleed && \"mx-auto max-w-6xl p-4 sm:p-6\")}>\n        {children}\n      </Page>\n      {footer !== undefined && (\n        <footer className=\"box-border border-0 border-t border-solid border-border px-4 py-6 text-base pointer-fine:text-sm text-muted-foreground sm:px-6\">\n          {footer}\n        </footer>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/sidebar/stacked-layout.tsx"
    }
  ],
  "docs": "The shell of an app with a `Navbar`: the bar across the top, in view while the page scrolls, an optional `toolbar` under it for the page's own tools, and the page below them in a centered column. Import: import { StackedLayout } from \"@/components/ouro/sidebar/stacked-layout\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: the helpers it imports in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/stacked-layout.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}