Streamlit Image Coordinates

0.4.0 · active · verified Wed Apr 15

Streamlit-image-coordinates is a Streamlit component that displays an image and returns the coordinates when a user clicks on it. It also provides the click event time in Unix format. The current stable version is `0.4.0`, and the library is actively maintained with regular updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to display an image and capture click coordinates using `streamlit_image_coordinates`. The returned `value` is a dictionary containing 'x', 'y', and optionally 'time'.

import streamlit as st
from streamlit_image_coordinates import streamlit_image_coordinates

st.title("Streamlit Image Coordinates Demo")

st.write("Click on the image to get its coordinates:")
value = streamlit_image_coordinates("https://placekitten.com/200/300")

if value:
    st.write(f"Clicked at: x={value['x']}, y={value['y']}")
    if 'time' in value:
        st.write(f"Click time (Unix): {value['time']}")
else:
    st.write("No click detected yet.")

view raw JSON →