@@ -196,9 +196,10 @@ def AppLayout(
196
196
children = [],
197
197
sidebar_open = True ,
198
198
title = None ,
199
+ show_app_bar : Optional [bool ] = None ,
199
200
navigation = True ,
200
- toolbar_dark = True ,
201
- color : Optional [str ] = "primary" ,
201
+ toolbar_dark : Optional [ bool ] = None ,
202
+ color : Optional [str ] = None ,
202
203
classes : List [str ] = [],
203
204
style : Optional [Union [str , Dict [str , str ]]] = None ,
204
205
):
@@ -222,9 +223,14 @@ def AppLayout(
222
223
223
224
# Arguments
224
225
225
- * `children`: The children of the AppLayout. The first child is used as the sidebar content, the rest as the main content.
226
+ * `children`: The children of the AppLayout. Note: Since Solara 2.0, the first child is no longer placed in the sidebar.
227
+ Use [Sidebar](/documentation/components/layout/sidebar) instead.
226
228
* `sidebar_open`: Whether the sidebar is open or not.
227
229
* `title`: The title of the app shown in the app bar, can also be set using the [Title](/documentation/components/page/title) component.
230
+ * `show_app_bar`: Whether the app bar should be shown. If `None` (the default), `AppBar` is shown if:
231
+ * There are one or more sibling routes to the current page.
232
+ * **OR**: There are one or more children of the `AppBar` component.
233
+ * **OR**: There are one or more children of the `AppBarTitle` component.
228
234
* `toolbar_dark`: Whether the toolbar should be dark or not.
229
235
* `navigation`: Whether the navigation tabs based on routing should be shown.
230
236
* `color`: The color of the toolbar.
@@ -243,18 +249,10 @@ def AppLayout(
243
249
244
250
sidebar_open , set_sidebar_open = solara .use_state_or_update (sidebar_open )
245
251
# remove the appbar from the children
246
- children_without_portal_sources = [c for c in children if c .component != AppBar ]
247
- use_drawer = len (children_without_portal_sources ) > 1
248
- children_content = children
249
- children_sidebar = []
250
- if use_drawer :
251
- child_sidebar = children_without_portal_sources .pop (0 )
252
- children_sidebar = [child_sidebar ]
253
- children_content = [c for c in children if c is not child_sidebar ]
254
- children_sidebar = children_sidebar + sidebar_portal .use_portal ()
252
+ children_content = [c for c in children if c .component != AppBar ]
253
+ children_sidebar = sidebar_portal .use_portal ()
254
+ use_drawer = len (children_sidebar ) > 0
255
255
children_appbar = appbar_portal .use_portal ()
256
- if children_sidebar :
257
- use_drawer = True
258
256
title = t .use_title_get () or title
259
257
children_appbartitle = apptitle_portal .use_portal ()
260
258
v_slots = []
@@ -269,7 +267,8 @@ def AppLayout(
269
267
children_appbar .remove (tabs )
270
268
tabs_to_render = tabs
271
269
272
- show_app_bar = (title and (len (routes ) > 1 and navigation )) or bool (children_appbar ) or bool (use_drawer ) or bool (children_appbartitle ) or bool (tabs )
270
+ if show_app_bar is None :
271
+ show_app_bar = (len (routes ) > 1 ) or bool (children_appbar ) or bool (use_drawer ) or bool (children_appbartitle ) or bool (tabs )
273
272
274
273
if style is None :
275
274
style = {"height" : "100%" , "max-height" : "100%" , "overflow" : "auto" }
@@ -284,7 +283,7 @@ def set_path(index):
284
283
if (tabs_to_render is None ) and routes and navigation and (len (routes ) > 1 ):
285
284
with solara .lab .Tabs (value = index , on_value = set_path , align = "center" ) as tabs_to_render :
286
285
for route in routes :
287
- name = route .path if route .path != "/" else "Home"
286
+ name = route .label if route . label is not None else ( route . path if route .path != "/" else "Home" )
288
287
solara .lab .Tab (name )
289
288
# with v.Tabs(v_model=index, on_v_model=set_path, centered=True) as tabs:
290
289
# for route in routes:
@@ -296,7 +295,7 @@ def set_path(index):
296
295
# this version doesn't need to run fullscreen
297
296
# also ideal in jupyter notebooks
298
297
with v .Html (tag = "div" ) as main :
299
- if show_app_bar or use_drawer :
298
+ if show_app_bar :
300
299
with v .AppBar (color = color , dark = toolbar_dark , v_slots = v_slots ):
301
300
if use_drawer :
302
301
icon = AppIcon (sidebar_open , on_click = lambda : set_sidebar_open (not sidebar_open ), v_on = "x.on" )
0 commit comments