Dev Helpers
← Back

Layout depth indicator

Place this file at components/LayoutDepthIndicator.tsx in an App Router project.

Open this example in the interactive library

Source code

"use client";

// components/LayoutDepthIndicator.tsx

import { useSelectedLayoutSegments } from "next/navigation";

export default function LayoutDepthIndicator() {
  const segments = useSelectedLayoutSegments().filter((s) => !s.startsWith("("));
  return (
    <small>
      {segments.length
        ? segments.length + " levels below this layout"
        : "Section overview"}
    </small>
  );
}