In a nutshell, I'm currently working on a project where my aim is to make the content "fill" the vertical space below the static header. Previously, in React with tailwind, I achieved this like so:
<body class="flex flex-col h-screen text-gray-600 work-sans leading-normal text-base tracking-normal">
<header class="flex h-18 bg-white shadow-md">
{/* header menu options */}
</header>
<div class="flex flex-1 h-full bg-gray-200 p-6">
{/* page content */}
</div>
However, with NextJS, it seems that the mounting div (i.e.
<div id="__next">
) is placed between the body and the rest of the content. If I adjust the CSS to apply #__next { height: 100% }
, the filling does not function correctly and causes overflow. The structure ends up looking like this:
<body class="flex flex-col h-screen text-gray-600 work-sans leading-normal text-base tracking-normal">
<div id="__next">
<header class="flex h-18 bg-white shadow-md">
{/* header menu options */}
</header>
<div class="flex flex-1 h-full bg-gray-200 p-6">
{/* page content */}
</div>
</div>
I have included screenshots for a visual representation of why the additional div is causing issues: https://i.sstatic.net/xZloH.jpg
Two possible solutions to resolve this issue theoretically are to add classes to the #__next
div or to mount to the body instead of the #__next
div. Does anyone know how to implement either of these?
Edit: It might be possible for me to change the layout to a fixed header with padding on top of the content element, which could bypass the problem. However, I am still curious about the feasibility of the solutions I mentioned, as if they are not viable, it would signify a technical limitation of NextJS that is not widely discussed.