1
0

icon_documentation.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.icon)
  4. def main_demo() -> None:
  5. ui.icon('thumb_up', color='primary').classes('text-5xl')
  6. @doc.demo('Material icons and symbols', r'''
  7. You can use different sets of Material icons and symbols.
  8. The [Quasar documentation](https://quasar.dev/vue-components/icon\#webfont-usage)
  9. gives an overview of all available icon sets and their name prefix:
  10. * None for [filled icons](https://fonts.google.com/icons?icon.set=Material+Icons&icon.style=Filled)
  11. * "o\_" for [outline icons](https://fonts.google.com/icons?icon.set=Material+Icons&icon.style=Outlined)
  12. * "r\_" for [round icons](https://fonts.google.com/icons?icon.set=Material+Icons&icon.style=Rounded)
  13. * "s\_" for [sharp icons](https://fonts.google.com/icons?icon.set=Material+Icons&icon.style=Sharp)
  14. * "sym\_o\_" for [outline symbols](https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Outlined)
  15. * "sym\_r\_" for [round symbols](https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded)
  16. * "sym\_s\_" for [sharp symbols](https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Sharp)
  17. ''')
  18. def material_icons():
  19. with ui.row().classes('text-4xl'):
  20. ui.icon('home')
  21. ui.icon('o_home')
  22. ui.icon('r_home')
  23. ui.icon('sym_o_home')
  24. ui.icon('sym_r_home')
  25. @doc.demo('Eva icons', '''
  26. You can use [Eva icons](https://akveo.github.io/eva-icons/) in your app.
  27. ''', lazy=False)
  28. def eva_icons():
  29. ui.add_head_html('<link href="https://unpkg.com/eva-icons@1.1.3/style/eva-icons.css" rel="stylesheet" />')
  30. ui.icon('eva-github').classes('text-5xl')
  31. @doc.demo('Other icon sets', '''
  32. You can use the same approach for adding other icon sets to your app.
  33. As a rule of thumb, you reference the corresponding CSS, and it in turn references font files.
  34. This demo shows how to include [Themify icons](https://themify.me/themify-icons).
  35. ''', lazy=False)
  36. def other_icons():
  37. ui.add_head_html('<link href="https://cdn.jsdelivr.net/themify-icons/0.1.2/css/themify-icons.css" rel="stylesheet" />')
  38. ui.icon('ti-car').classes('text-5xl')
  39. @doc.demo('Lottie files', '''
  40. You can also use [Lottie files](https://lottiefiles.com/) with animations.
  41. ''', lazy=False)
  42. def lottie():
  43. ui.add_body_html('<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>')
  44. src = 'https://assets5.lottiefiles.com/packages/lf20_MKCnqtNQvg.json'
  45. ui.html(f'<lottie-player src="{src}" loop autoplay />').classes('w-24')
  46. doc.reference(ui.icon)