# st.download_button

Source: https://docs.streamlit.io/develop/api-reference/widgets/st.download_button

* Function signature:

   ```python
   st.download_button(label, data, file_name=None, mime=None, key=None, help=None, on_click="rerun", args=None, kwargs=None, *, type="secondary", icon=None, icon_position="left", disabled=False, use_container_width=None, width="content", shortcut=None, wrap=None)
   ```

* Parameters:

   | name | type | default | description |
   |---|---|---|---|
   | label | str |  | A short label explaining to the user what this button is for. The label can optionally contain GitHub-flavored Markdown of the following types: Bold, Italics, Strikethroughs, Inline Code, Links, and Images. Images display like icons, with a max height equal to the font height. Unsupported Markdown elements are unwrapped so only their children (text contents) render. Common block-level Markdown (headings, lists, blockquotes) is automatically escaped and displays as literal text in labels. See the body parameter of st.markdown for additional, supported Markdown directives. |
   | data | str, bytes, file-like, or callable |  | The contents of the file to be downloaded or a callable that returns the contents of the file. File contents can be a string, bytes, or file-like object. File-like objects include io.BytesIO, io.StringIO, or any class that implements the abstract base class io.RawIOBase. If a callable is passed, it is executed when the user clicks the download button and runs on a separate thread from the resulting script rerun. This deferred generation is helpful for large files to avoid blocking the page script. The callable can't accept any arguments. If any Streamlit commands are executed inside the callable, they will be ignored. To prevent unnecessary recomputation, use caching when converting your data for download. For more information, see the Example 1 below. |
   | file_name | str |  | An optional string to use as the name of the file to be downloaded, such as "my_file.csv". If not specified, the name will be automatically generated. |
   | mime | str or None |  | The MIME type of the data. If this is None (default), Streamlit sets the MIME type depending on the value of data as follows:  If data is a file object with a string name attribute (e.g. a file opened with open()), Streamlit first tries to guess the MIME type from the file name (file_name if specified, otherwise data.name). If data is a string or textual file (i.e. str or io.TextIOWrapper object), Streamlit uses the "text/plain" MIME type. If data is a binary file or bytes (i.e. bytes, io.BytesIO, io.BufferedReader, or io.RawIOBase object), Streamlit uses the "application/octet-stream" MIME type.  For more information about MIME types, see https://www.iana.org/assignments/media-types/media-types.xhtml. |
   | key | str, int, or None |  | An optional string or integer to use as the unique key for the widget. If this is None (default), a key will be generated for the widget based on the values of the other parameters. No two widgets may have the same key. Assigning a key stabilizes the widget's identity and preserves its state across reruns even when other parameters change. A key lets you access the widget's value via st.session_state[key] (read-only). For more details, see Widget behavior. Additionally, if key is provided, it will be used as a CSS class name prefixed with st-key-. |
   | help | str or None |  | A tooltip that gets displayed when the button is hovered over. If this is None (default), no tooltip is displayed. The tooltip can optionally contain GitHub-flavored Markdown, including the Markdown directives described in the body parameter of st.markdown. |
   | on_click | callable, "rerun", "ignore", or None |  | How the button should respond to user interaction. This controls whether or not the button triggers a rerun and if a callback function is called. This can be one of the following values:  "rerun" (default): The user downloads the file and the app reruns. No callback function is called. "ignore": The user downloads the file and the app doesn't rerun. No callback function is called. A callable: The user downloads the file and app reruns. The callable is called before the rest of the app. None: This is same as on_click="rerun". This value exists for backwards compatibility and shouldn't be used. |
   | args | list or tuple |  | An optional list or tuple of args to pass to the callback. |
   | kwargs | dict |  | An optional dict of kwargs to pass to the callback. |
   | type | "primary", "secondary", or "tertiary" |  | An optional string that specifies the button type. This can be one of the following:  "primary": The button's background is the app's primary color for additional emphasis. "secondary" (default): The button's background coordinates with the app's background color for normal emphasis. "tertiary": The button is plain text without a border or background for subtlety. |
   | icon | str or None |  | An optional emoji or icon to display next to the button label. If icon is None (default), no icon is displayed. If icon is a string, the following options are valid:  A single-character emoji. For example, you can set icon="🚨" or icon="🔥". Emoji short codes are not supported.  An icon from the Material Symbols library (rounded style) in the format ":material/icon_name:" where "icon_name" is the name of the icon in snake case. For example, icon=":material/thumb_up:" will display the Thumb Up icon. Find additional icons in the Material Symbols  font library.  "spinner": Displays a spinner as an icon. |
   | icon_position | "left" or "right" |  | The position of the icon relative to the button label. This defaults to "left". |
   | disabled | bool | is | An optional boolean that disables the download button if set to True. The default is False. |
   | use_container_width | bool |  | Whether to expand the button's width to fill its parent container. If use_container_width is False (default), Streamlit sizes the button to fit its contents. If use_container_width is True, the width of the button matches its parent container. In both cases, if the contents of the button are wider than the parent container, the contents will line wrap. |
   | width | "content", "stretch", or int |  | The width of the download button. This can be one of the following:  "content" (default): The width of the button matches the width of its content, but doesn't exceed the width of the parent container. "stretch": The width of the button matches the width of the parent container. An integer specifying the width in pixels: The button has a fixed width. If the specified width is greater than the width of the parent container, the width of the button matches the width of the parent container. |
   | shortcut | str or None |  | An optional keyboard shortcut that triggers the button. This can be one of the following strings:  A single alphanumeric key like "K" or "4". A function key like "F11". A special key like "Enter", "Esc", or "Tab". Any of the above combined with modifiers. For example, you can use "Ctrl+K" or "Cmd+Shift+O".   Important The keys "C" and "R" are reserved and can't be used, even with modifiers. Punctuation keys like "." and "," aren't currently supported. Some combinations such as "Ctrl+T", "Ctrl+W", "Ctrl+PageUp", "Ctrl+PageDown", and "F11" are reserved by the browser or operating system and may never reach Streamlit.  For a list of supported keys and modifiers, see the documentation for st.button. |
   | wrap | bool or None |  | Whether the button label can wrap onto multiple lines. This can be one of the following:  None (default): Streamlit decides based on the surrounding layout. Inside a horizontal container or when directly placed in a column (not nested in another container), the button keeps its standard, single-row height and truncates an overflowing label with an ellipsis; in other layouts, the label wraps onto additional lines. True: If the label is too wide for the button, it wraps onto additional lines and the button grows taller. False: The button keeps its standard, single-row height. A label that is too wide is truncated with an ellipsis.  When a single-row label is truncated with an ellipsis and no help is set, hovering reveals the full label. Icons and keyboard shortcuts remain visible. |

* Returns: bool

    True if the button was clicked on the last run of the app,
False otherwise.
