HI,
is there a way please to customise the metric component like this :
thanks
Yes, you could utilize some custom CSS to achieve your desired result. For dynamic values, you can also use string templating.
import streamlit as st
# Custom CSS for the metric component
st.markdown(
"""
<style>
.metric-container {
background-color: #f9f9f9;
padding: 15px;
border-radius: 10px;
display: inline-block;
width: 200px;
text-align: center;
font-family: 'Arial', sans-serif;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 50px;
}
.metric-value {
font-size: 36px;
font-weight: bold;
color: black;
}
.metric-delta {
font-size: 18px;
color: red;
}
.metric-sub {
font-size: 14px;
color: gray;
}
</style>
""",
unsafe_allow_html=True
)
# Example metric display
st.markdown(
"""
<div class="metric-container">
<div class="metric-value">169</div>
<div>
<div class="metric-delta">-3.4% <span style="color: gray;">▼</span></div>
<div class="metric-sub">Moy. 175*<br>Moy. 160**</div>
</div>
</div>
""",
unsafe_allow_html=True
)
brialiant work.thanks
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.