list_documentation.py 1.8 KB

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