html_documentation.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.html)
  4. def main_demo() -> None:
  5. ui.html('This is <strong>HTML</strong>.')
  6. @doc.demo('Producing in-line elements', '''
  7. Use the `tag` parameter to produce something other than a div.
  8. ''')
  9. def demo_inline() -> None:
  10. ui.html('This is <u>emphasized</u>.', tag='em')
  11. @doc.demo('Other HTML Elements', '''
  12. There is also an `html` module that allows you to insert other HTML elements like `<span>`, `<div>`, `<p>`, etc.
  13. It is equivalent to using the `ui.element` method with the `tag` argument.
  14. Like with any other element, you can add classes, style, props, tooltips and events.
  15. One convenience is that the keyword arguments are automatically added to the element's `props` dictionary.
  16. ''')
  17. def other_html_elements():
  18. from nicegui import html, ui
  19. with html.section().style('font-size: 120%'):
  20. html.strong('This is bold.') \
  21. .classes('cursor-pointer') \
  22. .on('click', lambda: ui.notify('Bold!'))
  23. html.hr()
  24. html.em('This is italic.').tooltip('Nice!')
  25. with ui.row():
  26. html.img().props('src=https://placehold.co/60')
  27. html.img(src='https://placehold.co/60')
  28. doc.reference(ui.html)