Page layout with vertical scrollbar left to the right drawer #4660
ansyk
started this conversation in
Show and tell
Replies: 1 comment 2 replies
-
Interesting solution, @ansyk! Assuming you know (or control) the height of the header and footer, the following proof of concept might be worth considering: ui.context.client.content.classes('p-0')
with ui.scroll_area().classes('w-full h-[calc(100vh-6rem)]'):
ui.label('CONTENT')
[ui.label(f'Line {i}') for i in range(100)]
with ui.header().classes('h-12'):
ui.label('HEADER')
with ui.left_drawer(top_corner=True, bottom_corner=True, bordered=True):
ui.label('LEFT DRAWER')
with ui.right_drawer(bordered=True):
ui.label('RIGHT DRAWER')
with ui.footer().classes('h-12'):
ui.label('FOOTER') ![]() Note that "h-12" equals to "height: 3rem", so we can subtract 6rem from the full height of the viewport (100vh) to get the height of the scroll area. |
Beta Was this translation helpful? Give feedback.
2 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.
-
First of all congratulations for this useful and "nice" framework. I am rather new to Python and was glad to find something that nearly manages all of the browser frontend.
After some playing around I wanted that my application with the standard page layout has a body with a scrollbar left of the right drawer. However, this was difficult since, the body does not have a defined size. After a rather long research I arrived at the following solution, which I wanted to share.
The main obstacles were how to access the automatically created header and footer and to dynamically set the height of the scroll area, whenever the size of the browser window changes. The first problem was solved by setting the id of the footer and the header with the props property and accessing them then in Javascript with getElementyById. For the second problem I used "emitEvent" of the nicegui framework. It would be interesting, whether there is a solution without JavaScript.
As a side remark, which took me hours before I realized that the problem was not in my code, there seems to be an error in nicegui
Uncaught TypeError: ResizeObserver.observe: Argument 1 is not an object.
onload http://localhost:8080/:61
EventHandlerNonNull* http://localhost:8080/:57
localhost:8080:61:28
onload http://localhost:8080/:61
(Async: EventHandlerNonNull)
http://localhost:8080/:57
which is caused by following code snippet
I think that this is inserted by nicegui into the html header.
Beta Was this translation helpful? Give feedback.
All reactions