Load svg assets to use them in ui.icon #4203
Replies: 4 comments 1 reply
-
The code below is a workaround for some cases. with ui.button(icon=None):
ui.html(data_svg) |
Beta Was this translation helpful? Give feedback.
-
Hi @ThomasParistech, You can already use SVG files (or other image files) as icons using the "img:" prefix. You only need to serve them first as static files: app.add_static_files('/static', 'website/static')
ui.button('GitHub', icon='img:/static/github.svg') |
Beta Was this translation helpful? Give feedback.
-
Many thanks !! |
Beta Was this translation helpful? Give feedback.
-
@falkoschindler The code below gives me the linked screenshot: ui.icon("img:/static/star.svg", color="red")
ui.icon("info", color="red") |
Beta Was this translation helpful? Give feedback.
-
In the ui.icon doc, we see how to import icons from Themify or Eva.
However I have my custom icon saved as svg and would like to load it like you did for the NiceGUI's website but for further reuse as an icon.
For instance, I'd like to use
ui.button(icon="my-custom-loaded-svg")
Any idea ?
Many thanks
nicegui/website/svg.py
Lines 6 to 17 in e6fa211
Beta Was this translation helpful? Give feedback.
All reactions