element_documentation.py 706 B

12345678910111213141516171819202122232425
  1. from nicegui import ui
  2. from ..documentation_tools import text_demo
  3. def main_demo() -> None:
  4. with ui.element('div').classes('p-2 bg-blue-100'):
  5. ui.label('inside a colored div')
  6. def more() -> None:
  7. @text_demo('Move elements', '''
  8. This demo shows how to move elements between or within containers.
  9. ''')
  10. def move_elements() -> None:
  11. with ui.card() as a:
  12. ui.label('A')
  13. x = ui.label('X')
  14. with ui.card() as b:
  15. ui.label('B')
  16. ui.button('Move X to A', on_click=lambda: x.move(a))
  17. ui.button('Move X to B', on_click=lambda: x.move(b))
  18. ui.button('Move X to top', on_click=lambda: x.move(target_index=0))