list_documentation.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.list)
  4. def main_demo() -> None:
  5. with ui.list().props('dense separator'):
  6. ui.item('3 Apples')
  7. ui.item('5 Bananas')
  8. ui.item('8 Strawberries')
  9. ui.item('13 Walnuts')
  10. @doc.demo('Items, Sections and Labels', '''
  11. List items use item sections to structure their content.
  12. Item labels take different positions depending on their props.
  13. ''')
  14. def contact_list():
  15. with ui.list().props('bordered separator'):
  16. ui.item_label('Contacts').props('header').classes('text-bold')
  17. ui.separator()
  18. with ui.item(on_click=lambda: ui.notify('Selected contact 1')):
  19. with ui.item_section().props('avatar'):
  20. ui.icon('person')
  21. with ui.item_section():
  22. ui.item_label('Nice Guy')
  23. ui.item_label('name').props('caption')
  24. with ui.item_section().props('side'):
  25. ui.icon('chat')
  26. with ui.item(on_click=lambda: ui.notify('Selected contact 2')):
  27. with ui.item_section().props('avatar'):
  28. ui.icon('person')
  29. with ui.item_section():
  30. ui.item_label('Nice Person')
  31. ui.item_label('name').props('caption')
  32. with ui.item_section().props('side'):
  33. ui.icon('chat')
  34. doc.reference(ui.list, title='Reference for ui.list')
  35. doc.reference(ui.item, title='Reference for ui.item')
  36. doc.reference(ui.item_section, title='Reference for ui.item_section')
  37. doc.reference(ui.item_label, title='Reference for ui.item_label')