guillaume buffry
guillaume buffry
SSolara
Created by guillaume buffry on 1/9/2025 in #questions-issues
combining custom routes and custom layout
It seems when defining custom route that the custom layout is overridden. I tried with the custom layout in init or in s standalone page with the same result. I am doing this wrong? is there another of redirecting a route without having the default blue navigation bar? (I actually want to hide it) import solara @solara.component def Layout(children=[]): # Note that children being passed here for this example will be a Page() element. route_current, routes_all = solara.use_route() print(routes_all) with solara.Column(): # put all buttons in a single row with solara.Row(): for route in routes_all: with solara.Link(route): solara.Button(route.path, color="red" if route_current == route else None) # under the navigation buttons, we add our children (the single Page()) solara.Column(children=children) @solara.component def Page(): solara.Markdown("Page1")
router = solara.use_router() path = router.path parts = path.split("/") solara.Markdown(f"Path = {path!r}, and split up into {parts!r}") # now you can do anything with path or parts. # e.g. # if parts[0] == "docs": # solara.Markdown("You are in the docs section") routes = [ solara.Route(path="/", component=Page, label="home"), solara.Route(path="dev", component=Page, label="home"), ]
2 replies