How to create a page without any layout? #14613
-
How to create a page without any layout? E.g., not being wrapped by
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I'm not sure if it is possible (maybe there's some workaround for it). What I suggest is moving whatever layout you have in |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
It's not possible to break outside of the custom 1.) Limited to CSR See demo repo here for creating portals. A significantly better approach (also included in the demo repo above) would be to wrap individual pages with a reusable function Layout({ children, css }) {
return (
<div className="layout">
{children}
<style jsx>{`
.layout {
background: #1f1f1f;
margin-top: 100px;
padding: 10px;
color: pink;
${css};
}
`}</style>
</div>
);
}
export default Layout; |
Beta Was this translation helpful? Give feedback.
It's not possible to break outside of the custom
_app.js
file since it, by design, is supposed to wrap all client-side pages. That said, you can break outside of thediv.__next
element by using createPortal. However, there are two drawbacks:1.) Limited to CSR
2.) Technically still wrapped by the
_app
, but you'll lay over it using CSS (position: absolute; top: 0;
). As such, you'll also have to provide some CSS hacks to not display the _app's layout when the page is SSR'd.See demo repo here for creating portals.
A significantly better approach (also included in the demo repo above) would be to wrap individual pages with a reusable
Layout
component. If any of the pages required different …