Increasing Decimal Places with st.number_input()

Hi, I have a quick question with regards to using st.number_input(), is it possible for the step to be increased from 0.01 to something around 4 to 5 decimal places (e.g 0.00001) using this method, if not would there be any suggestions for obtaining an input from a user that is able to reach that much accuracy?

Many thanks.

Hi @thomsmd, welcome to the Streamlit community!! :wave: :partying_face:

It certainly is possible! You can specify the desired precision for the step size using the step parameter, and control how the number input widget displays numbers using printf-style strings. Here’s a working example:

import streamlit as st

num = st.number_input(
    "Higher precision step",
    min_value=1.0,
    max_value=5.0,
    step=1e-6,
    format="%.5f")

st.write(num)

Does this help?

Happy Streamlit-ing! :balloon:
Snehan

1 Like

Hi @snehankekre, thanks so much, this worked!

Best,
Thomas

1 Like