Proposal: Support for multiple "slot-based" outlets in TanStack Router #5397
discoverlance-com
started this conversation in
Ideas
Replies: 1 comment
-
|
+1, would be really useful in many cases though i thought of a bit different "inlet" api that might be a bit better: export const Route = createFileRoute('/foo/bar/baz')({
component: RouteComponent,
slotComponents: {
sidebar: EmployeeSidebar
}
})this way names of "slots" can also be statically typed (extracted by compiler from
additionally, it would be cool if we could specify "default" outlet content by passing children to the function ParentRouteComponent() {
return (
<>
<div class="sidebar">
<Outlet slot="sidebar">
<AppSidebar />
</Outlet>
</div>
<Outlet />
</>
)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi maintainers,
I’d like to discuss a potential enhancement for the router: support for multiple, named outlets (or “slots”) in a parent route. Currently,
Outletonly allows rendering child content in one place, which works well for simple nested routes. However, some layout use cases could benefit from being able to target multiple regions in the parent layout.For example, consider a root layout with a sidebar and main content area:
Here, the main content still uses the existing
Outlet, but the sidebar is a named slot. Child routes could then populate these slots independently, for example, suppose we have/employeesand/adminroutes which are children of theRootLayoutabove:Benefits of this approach:
I’d love to hear feedback from the community:
Thanks for considering!
Beta Was this translation helpful? Give feedback.
All reactions