Disable download button in data editor

I am using data editor to show the data on the page however it has download icon which allows anyone to easily download the data while. It has also has a find icon which is helpful as it highlights the text in data editor. I would like to keep the find icon and I want to disable the download button. What is the best way to disable the download icon and keep the search icon? @blackary

Hey @berohitverma, it looks like this GitHub issue is related to your question: Possibility to disable the "Download as CSV" button on st.dataframe/st.data_editor · Issue #8402 · streamlit/streamlit · GitHub
Based on the conversation there, it doesn’t look like we support an easy way to disable the download button for data editor at this moment.

1 Like

I posted a comment at GitHub. I am really looking for this feature or a way to do it as it poses a risk of data leakage (potentially with an icon/button that is built by the app designer). Do you think if this feature can be built? or if there are other ways to do it?

Great, replying and voting on the GitHub issue is the best action as it helps us to assess the demand for features and requests :slight_smile:
We have thought in the past about making the toolbar customizable but we don’t have anything concrete yet and also don’t know to what degree we would allow customization.

A workaround might be to leverage the HTML structure (e.g. classNam3) or so, and apply CSS on it. I am sure that this would be possible!
In the latest develop branch we have made some improvements on stabilizing our CSS names so that they do not change between releases. However, I don’t want to encourage this as we don’t consider it to be a very public API or approach :wink:

2 Likes

In terms of a temporary workaround, you can hide the button with CSS like this

import streamlit as st

data = {
    "foo": "bar",
    "bar": "foo",
}

st.dataframe(data)


st.html("""
<style>
[data-testid=stElementToolbarButton]:first-of-type {
    display: none;
}
</style>
""")

But as @raethlein said, this isn’t necessarily going to work in future releases, as the structure of the dataframe html may change.

1 Like