Help Regarding Multi-page

I currently have 2 separate script in the same folder. When I run the script, I want to be able to change page from one script to the other. I saw the multi-page support on the website but I don't want the button to be a tab. Instead, i created a button inside a sidebar and i want that button to be the button to press to change page. My question is how to make the button change page to the other script when it is pressed?
1 Reply
Egor Makarenko
Egor Makarenko6mo ago
You can look at tabs implementation in solara.AppLayout source code and create your own component with links to pages generated the same way as Solara does. Here is a HeaderMenu component I used to display tabs near the title instead of a separate vuetify slot:
@reacton.component
def HeaderMenu():
route_level = solara.use_route_level()
route, routes = solara.use_route(level=-route_level)
_, set_location_path = solara.use_pathname()
paths = [solara.resolve_path(r, level=0) for r in routes]
index = routes.index(route) if route else None

def set_path(i: int):
path = paths[i]
set_location_path(path)

with rv.Tabs(v_model=index, on_v_model=set_path) as menu:
for route in routes:
name = route.path.capitalize() if route.path != "/" else "Home"
rv.Tab(children=[name])

return menu
@reacton.component
def HeaderMenu():
route_level = solara.use_route_level()
route, routes = solara.use_route(level=-route_level)
_, set_location_path = solara.use_pathname()
paths = [solara.resolve_path(r, level=0) for r in routes]
index = routes.index(route) if route else None

def set_path(i: int):
path = paths[i]
set_location_path(path)

with rv.Tabs(v_model=index, on_v_model=set_path) as menu:
for route in routes:
name = route.path.capitalize() if route.path != "/" else "Home"
rv.Tab(children=[name])

return menu
Want results from more Discord servers?
Add your server