{"id":14970855,"url":"https://github.com/vivien000/st-clickable-images","last_synced_at":"2025-10-26T13:31:40.106Z","repository":{"id":112660642,"uuid":"454186386","full_name":"vivien000/st-clickable-images","owner":"vivien000","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-07T03:21:08.000Z","size":837,"stargazers_count":36,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T09:30:14.582Z","etag":null,"topics":["streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vivien000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-31T22:09:45.000Z","updated_at":"2024-10-07T13:24:41.000Z","dependencies_parsed_at":"2023-06-10T14:01:54.151Z","dependency_job_id":null,"html_url":"https://github.com/vivien000/st-clickable-images","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivien000%2Fst-clickable-images","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivien000%2Fst-clickable-images/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivien000%2Fst-clickable-images/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivien000%2Fst-clickable-images/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vivien000","download_url":"https://codeload.github.com/vivien000/st-clickable-images/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238337471,"owners_count":19455316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["streamlit"],"created_at":"2024-09-24T13:44:14.766Z","updated_at":"2025-10-26T13:31:34.369Z","avatar_url":"https://github.com/vivien000.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# st-clickable-image\n\n***[You might be interested by [st-click-detector](https://github.com/vivien000/st-click-detector) which generalizes this component]***\n\n`st-clickable-images` is a [Streamlit](https://streamlit.io) component to display one or several images and detect when they are clicked on.\n\n![Screenshot](screenshot.gif)\n\nA more advanced example can be seen live [here](https://huggingface.co/spaces/vivien/clip).\n\n## Installation\n\n```bash\npip install st-clickable-images\n```\n\n## Quickstart\n\n```python\nimport streamlit as st\nfrom st_clickable_images import clickable_images\n\nclicked = clickable_images(\n    [\n        \"https://images.unsplash.com/photo-1565130838609-c3a86655db61?w=700\",\n        \"https://images.unsplash.com/photo-1565372195458-9de0b320ef04?w=700\",\n        \"https://images.unsplash.com/photo-1582550945154-66ea8fff25e1?w=700\",\n        \"https://images.unsplash.com/photo-1591797442444-039f23ddcc14?w=700\",\n        \"https://images.unsplash.com/photo-1518727818782-ed5341dbd476?w=700\",\n    ],\n    titles=[f\"Image #{str(i)}\" for i in range(5)],\n    div_style={\"display\": \"flex\", \"justify-content\": \"center\", \"flex-wrap\": \"wrap\"},\n    img_style={\"margin\": \"5px\", \"height\": \"200px\"},\n)\n\nst.markdown(f\"Image #{clicked} clicked\" if clicked \u003e -1 else \"No image clicked\")\n```\n\nThis works as well with local images if you use `base64` encodings:\n\n```python\nimport base64\nimport streamlit as st\nfrom st_clickable_images import clickable_images\n\nimages = []\nfor file in [\"image1.jpeg\", \"image2.jpeg\"]:\n    with open(file, \"rb\") as image:\n        encoded = base64.b64encode(image.read()).decode()\n        images.append(f\"data:image/jpeg;base64,{encoded}\")\n\nclicked = clickable_images(\n    images,\n    titles=[f\"Image #{str(i)}\" for i in range(len(images))],\n    div_style={\"display\": \"flex\", \"justify-content\": \"center\", \"flex-wrap\": \"wrap\"},\n    img_style={\"margin\": \"5px\", \"height\": \"200px\"},\n)\n\nst.markdown(f\"Image #{clicked} clicked\" if clicked \u003e -1 else \"No image clicked\")\n```\n\n## Usage\n\n**clickable_images(paths,\n    titles=[],\n    div_style={},\n    img_style={},\n    key=None\n)**\n\nDisplays one or several images and returns the index of the last image clicked on (or -1 before any click)\n\n### Parameters\n\n- `paths` (list): the list of URLs of the images\n- `titles` (list): the (optional) titles of the images\n- `div_style` (dict): a dictionary with the CSS property/value pairs for the div container\n- `img_style` (dict): a dictionary with the CSS property/value pairs for the images\n- `key` (str or None): an optional key that uniquely identifies this component. If this is None, and the component's arguments are changed, the component will be re-mounted in the Streamlit frontend and lose its current state\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivien000%2Fst-clickable-images","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvivien000%2Fst-clickable-images","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivien000%2Fst-clickable-images/lists"}