Suppressing Spellchecker in st.text_area input box

Is there a way to suppress the spellchecking that appears in a st.text_area input box? I’m using it as an area where the user can edit Python code. It’s very distracting having a lot of red-underlined text.

How about using a widget specific for writing code, like for example streamlit-ace:


For st.text_area, you will need to set the spelling attribute to false using some js code:

import streamlit as st
from streamlit.components.v1 import html

txt = st.text_area(
    "Text to analyze",
    "Here is a word with a speling mistake",
)

js = """
<script>
const txt_areas = window.parent.document.querySelectorAll('div[data-testid="stTextArea"] textarea');
txt_areas.forEach(txt => {
    txt.spellcheck = false;
    }
);
</script>
"""

html(js, height=0)
2 Likes

Streamlit Ace sounds very interesting! Thanks for the advice regarding how st.text_area could be used too! Very helpful!

This has worked amazingly well, far surpassing my expectations. Thank you so much.

1 Like

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