Centre radio buttons

Summary

Hey there I’m trying to center these radio buttons but not sure on how to do it.

Steps to reproduce

Code snippet:

time = st.radio(label = ' ', options = ('1 Week', '1 Month', '3 Months', '6 Months', '1 Year', '3 Years', '5 Years'), horizontal = True)

Do you mean centering the st.radio options in the page?

If so, those can be centered using a CSS selector:

import streamlit as st

st.markdown("""
    <style>
    .stRadio [role=radiogroup]{
        align-items: center;
        justify-content: center;
    }
    </style>
""",unsafe_allow_html=True)

options = ["An option", "🦈", "Another option", "🎨", "x²"]

"# 🎯 Center align elements"
st.radio("Select an option", options=options, horizontal=True)

"****"
"Repeatedtext"*100

Thanks, thats exactly what I was after!

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