html_documentation.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_title := 'Other HTML Elements', other_html_elements_description := '''
  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. *Added in version 2.5.0*
  17. ''')
  18. def other_html_elements():
  19. from nicegui import html, ui
  20. with html.section().style('font-size: 120%'):
  21. html.strong('This is bold.') \
  22. .classes('cursor-pointer') \
  23. .on('click', lambda: ui.notify('Bold!'))
  24. html.hr()
  25. html.em('This is italic.').tooltip('Nice!')
  26. with ui.row():
  27. html.img().props('src=https://placehold.co/60')
  28. html.img(src='https://placehold.co/60')
  29. doc.reference(ui.html)