How to customize the width of the widgets?

I love the ease of Streamlit and I am trying to dig through the documentation and find some similar examples. One thing I am currently struggling with is, I don’t see an option to adjust the height or width of the widgets or even other components. Here is a very easily reproducible example, exaggerated to explain my point:

import streamlit as st

# Add a header
st.header('Streamlit Learning and Testing')

# Add a sidebar
rand_1 = st.sidebar.number_input('Random Value - 1')
rand_2 = st.sidebar.number_input('Random Value - 2')
rand_3 = st.sidebar.number_input('Random Value - 3')
rand_4 = st.sidebar.number_input('Random Value - 4')
rand_5 = st.sidebar.number_input('Random Value - 5')
rand_6 = st.sidebar.number_input('Random Value - 6')
rand_7 = st.sidebar.number_input('Random Value - 7')
rand_8 = st.sidebar.number_input('Random Value - 8')

# Add some operation widgets
selection_box = st.sidebar.selectbox(
    "Select a mathematical operation:",
    ('Addition', 'Subtract', 'Division', 'Exponent')

# Provide a run button
run = st.sidebar.button(label='Calculate')

In this case when the user needs to provide several inputs, it would be nice to have the ability to adjust the size of the widgets in the sidebar, so the user doesn’t have to scroll to the bottom to realize there are more inputs that are expected. Any thoughts on how to handle this ?


Personally I also find the widget size on a desktop monitor too large in general. What I do is to decrease the browser scaling/zoom (Ctrl+/- on the PC). If you save the page as an ‘app’ in chrome/edge the zoom level is even remembered by the ‘app’ . Then there are (beta) containers that allow you to put widgets side by side. Typically I have 4-5 input widgets as a single row.

1 Like

Thank you for your response @ksxx . I have gone down the path of using the beta components and ran into some issues as well. I have opened a separate issue regarding that here