How to make number_input display something that looks like currency?

Hey team: :balloon:

Is there a way to get st.number_input to display something that looks like currency?

I tried the following:

price = st.sidebar.number_input('Share Price', 100.00, format='$%f')

but it didn’t work:

StreamlitAPIException: Format string for st.number_input contains invalid characters: $%f

Traceback:
  File "/Users/adrien/Desktop/streamlit/small-st-projects/modeling_frb_loan.py", line 7, in <module>
    price = st.sidebar.number_input('Share Price', 100.00, format='$%f')

Thoughts? Thanks! :pray:

1 Like

Hi @Adrien_Treuille -

We have an open issue for this here:

Currently, we only support a handful of printf operators (%d %e %f %g %i) that can be passed to JavaScript; the linked issue suggests an improvement to formatting strings on the Python side.

Any update on implementing this functionality? It would be very helpful to allow for passing of f style print formats such as “{:,.0f}”. Great tool and appreciate the work!

4 Likes