Each element has a custom background color. What I want is when you click on an element, the output in the menu bar should give the same color as the element. Now it always gives the element a red color. So it is possible to change the color based on your choice of element. Here is a reproducible example:
import streamlit as st
# Styler
st.markdown(
"""
<style>
div[role="listbox"] li:nth-of-type(1){
background-color: red;
}
div[role="listbox"] li:nth-of-type(2){
background-color: blue;
}
</style>
""",
unsafe_allow_html=True,
)
# multiselect
st.multiselect("Options", ["option1", "option2", "option3"])
Output open menu:
Output option1:
Output option2:
As you can see option2 is again red, but it actually should be blue.



