# Can you draw with Streamlit?

**URL:** <https://discuss.streamlit.io/t/can-you-draw-with-streamlit/3008>\
**Category:** Using Streamlit\
**Tags:** matplotlib\
**Created:** [May 23, 2020, 6:15am UTC](https://discuss.streamlit.io/t/can-you-draw-with-streamlit/3008 "2020-05-23T06:15:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cysmith](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@cysmith](https://discuss.streamlit.io/u/cysmith)\
**Post date:** [May 23, 2020, 6:15am UTC](https://discuss.streamlit.io/t/can-you-draw-with-streamlit/3008/1 "2020-05-23T06:15:47Z")

</div>

Can you draw on a canvas using Streamlit? Especially draw according mouse events.  
[https://matplotlib.org/3.1.1/users/event\_handling.html](https://matplotlib.org/3.1.1/users/event_handling.html)

---

<div class="post-metadata">

**Author:** ![andfanilo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/andfanilo/32/1040_2.png) [@andfanilo](https://discuss.streamlit.io/u/andfanilo)\
**Post date:** [May 23, 2020, 8:33am UTC](https://discuss.streamlit.io/t/can-you-draw-with-streamlit/3008/2 "2020-05-23T08:33:32Z")

</div>

Hello @cysmith, welcome to the forums !

This is not natively supported by Streamlit but should be possible using the incoming [custom components](https://discuss.streamlit.io/t/interested-in-creating-and-or-testing-components/2962) in that you could expose a HTML canvas and return the content as a numpy array on mouse release.

If you’re interested to join in creating/testing some of those you’re welcome to join 😉

---

<div class="post-metadata">

**Author:** ![moskomule](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@moskomule](https://discuss.streamlit.io/u/moskomule)\
**Post date:** [October 4, 2020, 1:23pm UTC](https://discuss.streamlit.io/t/can-you-draw-with-streamlit/3008/3 "2020-10-04T13:23:49Z")

</div>

Hi, I’m also interested in drawing with Streamlit! Any updates?

---

<div class="post-metadata">

**Author:** ![ash2shukla](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/ash2shukla/32/2521_2.png) [@ash2shukla](https://discuss.streamlit.io/u/ash2shukla)\
**Post date:** [October 4, 2020, 2:40pm UTC](https://discuss.streamlit.io/t/can-you-draw-with-streamlit/3008/4 "2020-10-04T14:40:50Z")

</div>

Hi @moskomule, welcome to the community,

Yes now you can with this awesome component developed by @andfanilo , [https://github.com/andfanilo/streamlit-drawable-canvas](https://github.com/andfanilo/streamlit-drawable-canvas)

You can also use bokeh for this if your app is already using this plotting lib,

```python
from bokeh.plotting import figure
from bokeh.models import FreehandDrawTool

import streamlit as st

p = figure(x_range=(0, 10), y_range=(0, 10), width=400, height=400)

renderer = p.multi_line([[1, 1]], [[1, 1]], line_width=1, alpha=0.4, color='red')

draw_tool = FreehandDrawTool(renderers=[renderer], num_objects=99999)
p.add_tools(draw_tool)
p.toolbar.active_drag = draw_tool

st.bokeh_chart(p)

```

Hope it helps!

---

<div class="post-metadata">

**Author:** ![moskomule](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@moskomule](https://discuss.streamlit.io/u/moskomule)\
**Post date:** [October 5, 2020, 12:14am UTC](https://discuss.streamlit.io/t/can-you-draw-with-streamlit/3008/5 "2020-10-05T00:14:25Z")

</div>

Thank you! Super easy and impressive!

---

<div class="post-metadata">

**Author:** ![randyzwitch](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/randyzwitch/32/58772_2.png) [@randyzwitch](https://discuss.streamlit.io/u/randyzwitch)\
**Post date:** [January 12, 2022, 9:56pm UTC](https://discuss.streamlit.io/t/can-you-draw-with-streamlit/3008/6 "2022-01-12T21:56:56Z")

</div>


