Using Visual Studio Code editor as component

I wrapped the Monaco editor (the one from Visual Studio Code) in a Streamlit component.


Source: GitHub - marcusschiesser/streamlit-monaco: Monaco editor (Visual Studio Code) for Streamlit
PyPi: streamlit-monaco · PyPI


from streamlit_monaco import st_monaco
import streamlit as st

st.title("Streamlit Markdown Editor")

content = st_monaco(value="# Hello world", height="600px", language="markdown")

if st.button("Show editor's content"):

Does anyone know how I can add it to


That is so good!!

The components page gets populated automatically by looking in github, pypi and on the community tracker (Streamlit Components - Community Tracker) – I would recommend posting it on the community tracker, and then you can expect it to be added to the components page automatically when the next update happens.

Thanks @blackary , couldn’t edit the wiki post, so I left a new reply: Streamlit Components - Community Tracker - #31 by Marcus_Schiesser - I hope it works!

1 Like

Brilliant component. I’d like to use this but curious about the syntax and if the following is possible:

  1. How would I inject text into the component with a streamlit button? Would I update a session_state variable and do a st.rerun populating the session_state into the value?
  2. Is there a way to configure the monaco box via the streamlit parameters (i.e. add/remove line numbers, add menu items to the monaco component? etc…)

Thanks Joseph. I hope the following helps:

  1. Here’s a complicated example. The state is stored in a dataclass, which is stored again in the session_state:
  2. Yes, I already passed a couple of parameters, see - These are the ones I needed, happy to merge your PR with more parameters :slight_smile:

@Marcus_Schiesser thank you very much for this, I love the interactivity.

the only feature that I would suggest is to add an optional debounce in ms, so that if I am still typing, the content is not returned.

Yes that would be great. Anyone want to send a PR?

Thanks for this component. It would really be great to add an optional debounce in ms…


I love this component, but one issue I’m having with the built-in streamlit theme is that the text is pretty hard to read in dark mode. Any suggestions for still being able to switch from dark to light, but with the text a bit more readable?

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