Named Layout
At times related routes need to have drastically different layouts from their siblings. It is possible to define multiple layouts for different sibling routes. A single default layout and any number of named layouts. The child route can then request a specific named-layout.
Qwik City defines the convention that layouts are within src/routes
and the filename starts with layout
. That's why the default layout is named layout.tsx
. A named layout also starts with layout
followed by a dash -
and a unique name, such as layout-narrow.tsx
.
src/
โโโ routes/
โโโ contact/
โ โโโ index@narrow.tsx # https://example.com/contact (Layout: layout-narrow.tsx)
โโโ layout.tsx # Default layout
โโโ layout-narrow.tsx # Default named layout
โโโ index.tsx # https://example.com/ (Layout: layout.tsx)
https://example.com/
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ src/routes/layout.tsx โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ src/routes/index.tsx โ โ โ โ โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
https://example.com/contact
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ src/routes/layout-narrow.tsx โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ src/routes/contact/index@narrow.tsx โ โ โ โ โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ