Skip to content

Commit fb7c5cc

Browse files
stmtk1timdorr
andauthored
Add Layout Route Example (#10011)
Co-authored-by: Tim Dorr <[email protected]>
1 parent 0ce0e4c commit fb7c5cc

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
- souzasmatheus
153153
- srmagura
154154
- stasundr
155+
- stmtk1
155156
- tanayv
156157
- theostavrides
157158
- thisiskartik

docs/route/route.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,23 @@ let { org, "*": splat } = params;
205205

206206
### Layout Routes
207207

208-
<docs-info>TODO: expand with example</docs-info>
209-
210208
Omitting the path makes this route a "layout route". It participates in UI nesting, but it does not add any segments to the URL.
211209

210+
```tsx
211+
<Route
212+
element={
213+
<div>
214+
<h1>Layout</h1>
215+
<Outlet />
216+
</div>
217+
}
218+
>
219+
<Route path="/" element={<h2>Home</h2>} />
220+
<Route path="/about" element={<h2>About</h2>} />
221+
</Route>
222+
```
223+
In this example, `<h1>Layout</h1>` will be rendered along with each child route's `element` prop, via the layout route's [Outlet][outlet].
224+
212225
## `index`
213226

214227
Determines if the route is an index route. Index routes render into their parent's [Outlet][outlet] at their parent's URL (like a default child route).

0 commit comments

Comments
 (0)