As @Goyo has shown, it is working in the latest version, @Varshit_Dusad if deploying to Community Cloud, perhaps you can pin your Streamlit to the latest version either by leaving the version blank as in:
streamlit
or you could assign the latest version to it:
streamlit==1.28.2
or if it’s a local version, update to the latest version:
Thanks - looks like it is a version issue. Unfortunately, I am stuck an older version due to some other legacy libraries.
But will verify it with latest version.