Hide Export Button if DataTable is Empty

Is there a way to hide the ‘Export’ button if DataTable is empty?

Currently, it shows the button even though there is no data to show.

Hi @ims

You can style the Export button by updating the css property of the DataTable in a callback. See the example below.

Soon, you will be able to update the text and the classname of the Export button. This great pull request from a community member @jwbargsten is very close to the finishline: added className and text properties to DataTable to style export button by jwbargsten · Pull Request #799 · plotly/dash-table · GitHub

import dash
import dash_table
import pandas as pd

df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/solar.csv")

app = dash.Dash(__name__)

app.layout = dash_table.DataTable(
    columns=[{"name": i, "id": i} for i in df.columns],

    Output("table", "css"), Input("table", "derived_virtual_data"),
def style_export_button(data):
    if data == []:
        return [{"selector": ".export", "rule": "display:none"}]
        return [{"selector": ".export", "rule": "display:block"}]

if __name__ == "__main__":