link_documentation.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from nicegui import ui
  2. from ..documentation_tools import text_demo
  3. from ..style import link_target
  4. def main_demo() -> None:
  5. ui.link('NiceGUI on GitHub', 'https://github.com/zauberzeug/nicegui')
  6. def more() -> None:
  7. @text_demo('Navigate on large pages', '''
  8. To jump to a specific location within a page you can place linkable anchors with `ui.link_target('target_name')`
  9. or simply pass a NiceGUI element as link target.
  10. ''')
  11. def same_page_links():
  12. navigation = ui.row()
  13. # ui.link_target('target_A')
  14. link_target('target_A', '-10px') # HIDE
  15. ui.label(
  16. 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, '
  17. 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
  18. )
  19. link_target('target_B', '70px') # HIDE
  20. label_B = ui.label(
  21. 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
  22. 'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.'
  23. 'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
  24. )
  25. with navigation:
  26. ui.link('Goto A', '#target_A')
  27. # ui.link('Goto B', label_B)
  28. ui.link('Goto B', '#target_B') # HIDE
  29. @text_demo('Links to other pages', '''
  30. You can link to other pages by providing the link target as path or function reference.
  31. ''')
  32. def link_to_other_page():
  33. @ui.page('/some_other_page')
  34. def my_page():
  35. ui.label('This is another page')
  36. ui.label('Go to other page')
  37. ui.link('... with path', '/some_other_page')
  38. ui.link('... with function reference', my_page)