section_text_elements.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from . import (
  2. chat_message_documentation,
  3. doc,
  4. element_documentation,
  5. html_documentation,
  6. label_documentation,
  7. link_documentation,
  8. markdown_documentation,
  9. mermaid_documentation,
  10. restructured_text_documentation,
  11. )
  12. doc.title('*Text* Elements')
  13. doc.intro(label_documentation)
  14. doc.intro(link_documentation)
  15. doc.intro(chat_message_documentation)
  16. doc.intro(element_documentation)
  17. doc.intro(markdown_documentation)
  18. doc.intro(restructured_text_documentation)
  19. doc.intro(mermaid_documentation)
  20. doc.intro(html_documentation)
  21. @doc.demo('Other HTML Elements', '''
  22. There is an `html` module that allows you to insert other HTML elements like `<span>`, `<div>`, `<p>`, etc.
  23. It is equivalent to using the `ui.element` method with the `tag` argument.
  24. Like with any other element, you can add classes, style, props, tooltips and events.
  25. One convenience is that the keyword arguments are automatically added to the element's `props` dictionary.
  26. ''')
  27. def other_html_elements():
  28. from nicegui import html, ui
  29. with html.section().style('font-size: 120%'):
  30. html.strong('This is bold.') \
  31. .classes('cursor-pointer') \
  32. .on('click', lambda: ui.notify('Bold!'))
  33. html.hr()
  34. html.em('This is italic.').tooltip('Nice!')
  35. with ui.row():
  36. html.img().props('src=https://placehold.co/60')
  37. html.img(src='https://placehold.co/60')