---
title: "How to use parameters"
description: "Basic, nested, and dynamic-data `Parameter`s that update non-data arguments of a component's `figure`, plus title, tooltip, and selector customization."
source_url: "https://vizro.readthedocs.io/en/stable/pages/user-guides/parameters/"
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 parameters

This guide shows you how to add parameters to your dashboard. A parameter sets any argument other than `data_frame` in the `figure` function of a component. For example, a user could select using a dropdown which variable is plotted on the x-axis of a graph. Parameters can also be used to set [dynamic data parameters](https://vizro.readthedocs.io/en/stable/pages/user-guides/parameters/#dynamic-data-parameters). The following [components](https://vizro.readthedocs.io/en/stable/pages/user-guides/components/) are reactive to parameters:

- [built-in graphs](https://vizro.readthedocs.io/en/stable/pages/user-guides/graph/) and [custom graphs](https://vizro.readthedocs.io/en/stable/pages/user-guides/custom-charts/)
- [built-in tables](https://vizro.readthedocs.io/en/stable/pages/user-guides/table/) and [custom tables](https://vizro.readthedocs.io/en/stable/pages/user-guides/custom-tables/)
- [built-in figures](https://vizro.readthedocs.io/en/stable/pages/user-guides/figure/) and [custom figures](https://vizro.readthedocs.io/en/stable/pages/user-guides/custom-figures/)

It is possible to add parameters to a [page](https://vizro.readthedocs.io/en/stable/pages/user-guides/pages/) or [container](https://vizro.readthedocs.io/en/stable/pages/user-guides/container/#add-controls-to-container). Both the [`Page` model](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Page "            Page


  
      pydantic-model
  ") and the [`Container` model](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Container "            Container


  
      pydantic-model
  ") have an optional `controls` argument where you can give any number of controls including parameters.

When the dashboard is running there are two ways for a user to set a parameter:

- Direct user interaction with the underlying selector. For example, the user selects values from a checklist.
- [User interaction with a graph or table](https://vizro.readthedocs.io/en/stable/pages/user-guides/graph-table-actions/#cross-parameter) via the [`set_controls` action](https://vizro.readthedocs.io/en/stable/pages/API-reference/actions/#vizro.actions.set_controls "            set_controls


    
        pydantic-model
    "). This enables functionality such as [cross-highlighting](https://vizro.readthedocs.io/en/stable/pages/user-guides/graph-table-actions/#cross-highlight). To achieve a visually cleaner dashboard you might like to hide the parameter's underlying selector with `visible=False`.

## Basic parameters

To add a parameter to your page, do the following:

1. add the [`Parameter`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Parameter "            Parameter


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


     
         pydantic-model
     ") model.
2. add the `targets` argument
3. add a selector model to the `selector` argument.

In the `targets` argument, specify the component and the argument you want to parametrize by joining the component's `id` and the argument name with a dot. For example, `scatter_chart.title` parametrizes the `title` argument of the component with `id="scatter_chart"`. You can additionally include another control's `id` in `targets` to [keep multiple controls in sync](https://vizro.readthedocs.io/en/stable/pages/user-guides/controls/#sync-controls); a parameter must still target at least one component argument as well.

Unlike for the [`Filter`](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Filter "            Filter


  
      pydantic-model
  ") model, you also have to configure the `selector` argument, by providing it with an appropriate model and the desired options/numeric ranges.

Basic Parameter

app.pyapp.yamlResult

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

iris = px.data.iris()

page = vm.Page(
    title="My first page",
    components=[
        vm.Graph(
            id="scatter_chart",
            figure=px.scatter(iris, title="My scatter chart", x="sepal_length", y="petal_width", color="species"),
        ),
    ],
    controls=[
        vm.Parameter(
            targets=["scatter_chart.title"],
            selector=vm.Dropdown(
                options=["My scatter chart", "A better title!", "Another title..."],
                multi=False,
            ),
        ),
    ],
)

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:
      - figure:
          _target_: scatter
          data_frame: iris
          x: sepal_length
          y: petal_width
          color: species
        id: scatter_chart
        type: graph
    controls:
      - selector:
          options: [My scatter chart, A better title!, Another title...]
          multi: false
          type: dropdown
        targets:
          - scatter_chart.title
        type: parameter
    title: My first page
```

The dashboard renders the "Basic Parameter" example.

[![Parameter](https://vizro.readthedocs.io/en/stable/assets/user_guides/control/control4.png)](https://vizro.readthedocs.io/en/stable/assets/user_guides/control/control4.png)

If you would like to pass `None` as a parameter and make a parameter optional, you can specify the string `"NONE"` in the `options` or `value` field.

## Nested parameters

If you want to change nested parameters, extend the `targets` argument with another dot and the nested key. For example, `scatter_chart.color_discrete_map.virginica` parametrizes the `virginica` key of the `color_discrete_map` argument of the component with `id="scatter_chart"`.

Nested Parameters for multiple targets

app.pyapp.yamlResult

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

iris = px.data.iris()

page = vm.Page(
    title="My first page",
    components=[
        vm.Graph(
            id="scatter_chart",
            figure=px.scatter(
                iris,
                x="sepal_width",
                y="sepal_length",
                color="species",
                size="petal_length",
                color_discrete_map={"setosa": "#097DFE", "versicolor": "#6F39E3"},
            ),
        ),
        vm.Graph(
            id="bar_chart",
            figure=px.bar(
                iris,
                x="sepal_width",
                y="sepal_length",
                color="species",
                color_discrete_map={"setosa": "#097DFE", "versicolor": "#6F39E3"},
            ),
        ),
    ],
    controls=[
        vm.Parameter(
            targets=["scatter_chart.color_discrete_map.virginica", "bar_chart.color_discrete_map.virginica"],
            selector=vm.Dropdown(
                options=["#05D0F0", "#0F766E"],
                multi=False,
                value="#05D0F0",
            ),
        ),
    ],
)

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:
      - figure:
          _target_: scatter
          data_frame: iris
          x: sepal_width
          y: sepal_length
          size: petal_length
          color: species
          color_discrete_map: {setosa: '#00b4ff', versicolor: '#ff9222'}
        id: scatter_chart
        type: graph
      - figure:
          _target_: bar
          data_frame: iris
          x: sepal_width
          y: sepal_length
          color: species
          color_discrete_map: {setosa: '#00b4ff', versicolor: '#ff9222'}
        id: bar_chart
        type: graph
    controls:
      - selector:
          options: ['#ff5267', '#3949ab']
          value: #3949ab
          multi: false
          type: dropdown
        targets:
          - scatter_chart.color_discrete_map.virginica
          - bar_chart.color_discrete_map.virginica
        type: parameter
    title: My first page
```

The dashboard renders the "Nested Parameters for multiple targets" example.

[![Nested](https://vizro.readthedocs.io/en/stable/assets/user_guides/control/control5.png)](https://vizro.readthedocs.io/en/stable/assets/user_guides/control/control5.png)

In the [Nested parameters](https://vizro.readthedocs.io/en/stable/pages/user-guides/parameters/#nested-parameters) example, the object passed to the function argument `color_discrete_map` is a dictionary which maps the different flower species to fixed colors (for example, `{"virginica":"blue"}`). In this case, only the value `blue` should be changed instead of the entire dictionary. This can be achieved by specifying a target as `scatter.color_discrete_map.virginica`.

Note that in the [Nested parameters](https://vizro.readthedocs.io/en/stable/pages/user-guides/parameters/#nested-parameters) example, one parameter affects multiple targets.

## Dynamic data parameters

If you use [dynamic data](https://vizro.readthedocs.io/en/stable/pages/user-guides/data/#dynamic-data) that can be updated while the dashboard is running then you can pass parameters to the dynamic data function to alter the data loaded into your dashboard. For detailed instructions, refer to the section on [parametrized data loading](https://vizro.readthedocs.io/en/stable/pages/user-guides/data/#parametrize-data-loading).

## Further customization

For further customizations, refer to the [guide to selectors](https://vizro.readthedocs.io/en/stable/pages/user-guides/selectors/) and the [`Parameter` model](https://vizro.readthedocs.io/en/stable/pages/API-reference/models/#vizro.models.Parameter "            Parameter


  
      pydantic-model
  "). Some popular choices are:

- Customize the `selector`. For example: `multi`, to switch between a multi-option and single-option selector; `options` for a categorical parameter; or `min` and `max` for a numerical parameter.
- Make the parameter's selector invisible by setting `visible=False`. This is particularly useful for graph interactions to hide the selector from the user interface while keeping the functionality active. Cross-highlighting is a common example of this pattern. For a complete code example, see the [cross-highlighting section](https://vizro.readthedocs.io/en/stable/pages/user-guides/graph-table-actions/#cross-highlight) in the graph and table interactions guide.
- Stop the parameter from applying as soon as its value changes by setting its selector's `actions=None`, then apply it on demand with a button. See [apply controls with a button](https://vizro.readthedocs.io/en/stable/pages/user-guides/controls/#apply-controls-with-a-button).
