Using rendered .svg files within st.selectbox

Hello dear Community,

This is my first post ever here - I hope, I’m doing this right.

I was wondering, if it’s possible to use rendered svg files together with string values inside the st.selectbox function ?

For example, when using st.stelectbox to choose a country, show the options with a svg file of the actual flag of the country and the country name by string. Such as: {flag.svg} - {country-string}

Thank you very much in advance to everyone!

In the case of flags, you could use emojis instead of reading the flag images.

import streamlit as st

countries = ["🇺🇸 USA", "🇫🇷 France", "🇯🇵 Japan"]
option = st.selectbox("Pick a country", countries)
f"**You picked {option}**"

Hey there,

Thank you for your reply!

That’s definitely a cool workaround for the flag specific case, however, I’d also like to use this for other images / icons / .svgs

Do you have any idea how I could do that ?

Thank you still for your help, really appreciate it!


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.