Set focus to a text_input

I’m sure this has been answered, but I can’t find it here. Is there a way to set the focus to text_input?

FR

1 Like

As I was researching this feature recently, two links:

Thank you.

Just to follow up on this subject. I have tested this method:

# this part of the code focuses input on text window
components.html(
    f"""
        <div>some hidden container</div>
        <p>{st.session_state.counter}</p>
        <script>
            var input = window.parent.document.querySelectorAll("input[type=text]");
            for (var i = 0; i < input.length; ++i) {{
                input[i].focus();
            }}
    </script>
    """,
    height=0,
)

and it works very well. You just need to put some counter in your code.

1 Like

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