page_layout_documentation.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo('Page Layout', '''
  4. With `ui.header`, `ui.footer`, `ui.left_drawer` and `ui.right_drawer` you can add additional layout elements to a page.
  5. The `fixed` argument controls whether the element should scroll or stay fixed on the screen.
  6. The `top_corner` and `bottom_corner` arguments indicate whether a drawer should expand to the top or bottom of the page.
  7. See <https://quasar.dev/layout/header-and-footer> and <https://quasar.dev/layout/drawer> for more information about possible props.
  8. With `ui.page_sticky` you can place an element "sticky" on the screen.
  9. See <https://quasar.dev/layout/page-sticky> for more information.
  10. ''')
  11. def page_layout_demo():
  12. @ui.page('/page_layout')
  13. def page_layout():
  14. ui.label('CONTENT')
  15. [ui.label(f'Line {i}') for i in range(100)]
  16. with ui.header(elevated=True).style('background-color: #3874c8').classes('items-center justify-between'):
  17. ui.label('HEADER')
  18. ui.button(on_click=lambda: right_drawer.toggle(), icon='menu').props('flat color=white')
  19. with ui.left_drawer(top_corner=True, bottom_corner=True).style('background-color: #d7e3f4'):
  20. ui.label('LEFT DRAWER')
  21. with ui.right_drawer(fixed=False).style('background-color: #ebf1fa').props('bordered') as right_drawer:
  22. ui.label('RIGHT DRAWER')
  23. with ui.footer().style('background-color: #3874c8'):
  24. ui.label('FOOTER')
  25. ui.link('show page with fancy layout', page_layout)
  26. doc.reference(ui.header, title='Header')
  27. doc.reference(ui.left_drawer, title='Left Drawer')
  28. doc.reference(ui.right_drawer, title='Right Drawer')
  29. doc.reference(ui.footer, title='Footer')
  30. doc.reference(ui.page_sticky, title='Page Sticky')