---
title: "How to use buttons"
description: "Configure `Button` text, link URLs, action triggers, use as a control, styled variants, tooltips, icons, and the `extra` pass-through argument."
source_url: "https://vizro.readthedocs.io/en/stable/pages/user-guides/button/"
agent_docs: "Index: https://vizro.readthedocs.io/en/stable/llms.txt; full documentation: https://vizro.readthedocs.io/en/stable/llms-full.txt"
---

# How to use buttons

This guide shows you how to use buttons to interact with your data in the dashboard.

When to use this

Choose `Button` to let users trigger an [action](https://vizro.readthedocs.io/en/stable/pages/user-guides/actions/), submit a form, or navigate to a URL. For a control that filters or parametrizes data, use a [`Filter`](https://vizro.readthedocs.io/en/stable/pages/user-guides/filters/) or [`Parameter`](https://vizro.readthedocs.io/en/stable/pages/user-guides/parameters/) instead; for text-only content use [`Card`](https://vizro.readthedocs.io/en/stable/pages/user-guides/card/) or [`Text`](https://vizro.readthedocs.io/en/stable/pages/user-guides/text/); to make a `Card` clickable for navigation see [`Card`'s navigation tile](https://vizro.readthedocs.io/en/stable/pages/user-guides/card/#create-a-navigation-card).

**API reference:** [`Button`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Button "            Button


  
      pydantic-model
  ")

The Button component is commonly used for dashboard interactions such as form submissions, navigation links, and other action triggers. It is based on the underlying Dash component [`dbc.Button`](https://www.dash-bootstrap-components.com/docs/components/button/).

To add a [`Button`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Button "            Button


  
      pydantic-model
  "), insert it into the `components` argument of the [`Page`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Page "            Page


  
      pydantic-model
  ") model.

## Customize button text

You can configure the `text` argument to alter the display text of the [`Button`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Button "            Button


  
      pydantic-model
  ").

Customize text

app.pyapp.yamlResult

```python
import vizro.models as vm
from vizro import Vizro

page = vm.Page(
    title="Button with text",
    components=[vm.Button(text="I'm a button!")],
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```

```yaml
# Still requires a .py to add data to the data manager and parse YAML configuration
# See yaml_version example
pages:
  - components:
      - type: button
        text: I'm a button!
    title: Button with text
```

The dashboard renders the "Customize text" example.

[![ButtonText](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button_text.png)](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button_text.png)

## Create a link button

To navigate to a different page using a button with an anchor tag, assign an absolute or relative URL to the `Button.href`.

```python
import vizro.models as vm

vm.Button(text="Leave us a star! ⭐", href="https://github.com/mckinsey/vizro")
```

## Trigger an action

You can use the [`Button`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Button "            Button


  
      pydantic-model
  ") to trigger actions. These actions could be [built-in](https://vizro.readthedocs.io/en/stable/pages/user-guides/actions/#trigger-an-action-with-a-button) or [custom](https://vizro.readthedocs.io/en/stable/pages/user-guides/custom-actions/#trigger-an-action-with-a-button). Use the `Button.actions` argument to configure the action that executes when the button is clicked.

The example below shows how to configure a button that exports the filtered data from a target chart using the [`export_data`](https://vizro.readthedocs.io/en/stable/pages/user-guides/data-actions/#export-data) action.

If your app includes several action buttons, consider [adding icons](https://vizro.readthedocs.io/en/stable/pages/user-guides/button/#add-an-icon). You can also use icon-only buttons without text, but keep in mind that these work best when the icon is universally recognizable (for example, a download arrow for exports). For less common actions, you should include text on your button to make it clear what it does.

Button with action

app.pyapp.yamlResult

```python
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro
import vizro.actions as va

df = px.data.iris()

page = vm.Page(
    title="My first page",
    layout=vm.Flex(),  # (1)!
    components=[
        vm.Graph(
            figure=px.scatter(
                df,
                x="sepal_width",
                y="sepal_length",
                color="species",
                size="petal_length",
            ),
        ),
        vm.Button(
            text="Export data",
            actions=va.export_data(),
        ),
    ]
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```

1. We use a [`Flex`](https://vizro.readthedocs.io/en/stable/pages/user-guides/layouts/#flex-layout) layout to make sure the `Graph` and `Button` only occupy as much space as they need, rather than being distributed evenly.

```yaml
# Still requires a .py to add data to the data manager and parse YAML configuration
# See yaml_version example
pages:
  - components:
      - figure:
          _target_: scatter
          x: sepal_width
          y: sepal_length
          color: species
          size: petal_length
          data_frame: iris
        type: graph
      - type: button
        text: Export data
        id: export_data
        actions:
          - type: export_data
    layout:
      type: flex
    title: My first page
```

The dashboard renders the "Button with action" example.

[![Button](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button.png)](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button.png)

## Use as a control

The [`Button`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Button "            Button


  
      pydantic-model
  ") component is currently reserved to be used inside the main panel (right-side) of the dashboard. However, there might be use cases where one would like to place the `Button` inside the control panel (left-side) with the other controls.

In this case, follow the user-guide outlined for [creating custom components](https://vizro.readthedocs.io/en/stable/pages/user-guides/custom-components/) and manually add the `Button` as a valid type to the `controls` argument by running the following lines before your dashboard configurations:

```python
from vizro import Vizro
import vizro.models as vm

vm.Page.add_type("controls", vm.Button)

# Add dashboard configurations below
...
```

## Styled buttons

There are three predefined button styles that can be customized using the `variant` argument. If no `variant` is specified, the default style applied is `variant="filled"`.

Button with different styles

app.pyapp.yamlResult

```python
import vizro.models as vm
from vizro import Vizro

page = vm.Page(
    title="Buttons with different styles",
    layout=vm.Flex(direction="row"),  # (1)!
    components=[
        vm.Button(text="filled"),
        vm.Button(text="outlined", variant="outlined"),
        vm.Button(text="plain", variant="plain"),
    ],
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```

1. We use a [`Flex`](https://vizro.readthedocs.io/en/stable/pages/user-guides/layouts/#flex-layout) layout with `direction="row"` to ensure the `Button` components are placed side by side and only take up as much space as needed.

```yaml
# Still requires a .py to add data to the data manager and parse YAML configuration
# See yaml_version example
pages:
  - title: Buttons with different styles
    layout:
      direction: row
      type: flex
    components:
      - type: button
        text: filled
      - type: button
        text: outlined
        variant: outlined
      - type: button
        text: plain
        variant: plain
```

The dashboard renders the "Button with different styles" example.

[![ButtonVariant](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button_style_variants.png)](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button_style_variants.png)

## Add a tooltip

The `description` argument enables you to add helpful context to your button by displaying an info icon next to its text. Hovering over the icon shows a tooltip with your chosen text.

You can provide [Markdown text](https://markdown-guide.readthedocs.io/) as a string to use the default info icon or a [`Tooltip`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Tooltip "            Tooltip


  
      pydantic-model
  ") model to use any icon from the [Google Material Icons library](https://fonts.google.com/icons).

Button with a tooltip

app.pyapp.yamlResult

```python
import vizro.models as vm
from vizro import Vizro

page = vm.Page(
    title="Buttons with tooltip",
    components=[
        vm.Button(
            text="Click me!",
            description="Once you click this button, the process will start.",
        ),
    ],
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```

```yaml
pages:
  - title: Buttons with tooltip
    components:
      - type: button
        text: Click me!
        description: Once you click this button, the process will start.
```

The dashboard renders the "Button with a tooltip" example.

[![ButtonTooltip](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button_tooltip.png)](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button_tooltip.png)

## Add an icon

The `icon` argument enables you to add an icon to your button, using any icon from the [Google Material Icons library](https://fonts.google.com/icons).

You can use it alongside the `text` argument, or on its own to create a circular icon-only button.

Button with an icon

app.pyapp.yamlResult

```python
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro

iris = px.data.iris()

page = vm.Page(
    title="Buttons with an icon",
    layout=vm.Flex(),
    components=[
        vm.Button(
            icon="Download",
            description="Download the data!",
            variant="outlined",
        ),
        vm.Graph(
            figure=px.scatter(
                iris,
                x="sepal_width",
                y="sepal_length",
                color="species",
                size="petal_length",
            ),
        ),
        vm.Button(
            text="View Data Source",
            href="https://www.kaggle.com/datasets/uciml/iris",
            icon="Link",
            variant="outlined",
        ),
    ],
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```

```yaml
pages:
  - title: Buttons with an icon
    components:
      - type: button
        icon: Download
        description: Download the data!
        actions:
          - type: export_data
      - figure:
          _target_: scatter
          x: sepal_width
          y: sepal_length
          color: species
          size: petal_length
          data_frame: iris
        type: graph
      - type: button
        text: Visit link to learn more!
        href: https://www.kaggle.com/datasets/uciml/iris
        icon: Link
        variant: outlined
```

The dashboard renders the "Button with an icon" example.

[![ButtonIcon](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button-with-an-icon.png)](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button-with-an-icon.png)

## The `extra` argument

The `Button` is based on the underlying Dash component [`dbc.Button`](https://www.dash-bootstrap-components.com/docs/components/button/). Using the `extra` argument you can pass more arguments to `dbc.Button` in order to alter it beyond the chosen defaults.

Warning

Using `extra` is a quick and flexible way to alter a component beyond what Vizro offers. However, [it is not a part of the official Vizro schema](https://vizro.readthedocs.io/en/stable/pages/explanation/schema/#what-is-the-vizro-json-schema) and the underlying implementation details may change. If you want to guarantee that your apps keep running, we recommend that you pin your Vizro version.

An example use would be to create an outlined success button. For this, you can use `extra={"color": "success", "outline": True}`. This would be a shortcut to using custom CSS in the assets folder as explained in [our guide on CSS](https://vizro.readthedocs.io/en/stable/pages/user-guides/custom-css/).

Button with custom style

app.pyapp.yamlResult

```python
import vizro.models as vm
from vizro import Vizro

page = vm.Page(
    title="Button with custom style",
    components=[
        vm.Button(
            text="Success button",
            extra={"color": "success", "outline": True},
        ),
    ],
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```

```yaml
pages:
  - title: Button with custom style
    components:
      - type: button
        text: Success button
        extra:
          color: success
          outline: true
```

The dashboard renders the "Button with custom style" example.

[![ButtonExtra](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button_style_extra.png)](https://vizro.readthedocs.io/en/stable/assets/user_guides/components/button_style_extra.png)
