# DashboardVariableOptions

Options for {@link DashboardVariable}.

Extends: DashboardVariableOptions
Used as props by: DashboardVariable

- Source: [`aws-cloudwatch/lib/variable.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cloudwatch/lib/variable.ts#L177)
- Type last changed: v2.88.0 · 20 Jul 2023

## Example

```ts
import * as cw from 'aws-cdk-lib/aws-cloudwatch';

const dashboard = new cw.Dashboard(this, 'Dash', {
  defaultInterval: Duration.days(7),
  variables: [new cw.DashboardVariable({
    id: 'functionName',
    type: cw.VariableType.PATTERN,
    label: 'Function',
    inputType: cw.VariableInputType.RADIO,
    value: 'originalFuncNameInDashboard',
    // equivalent to cw.Values.fromSearch('{AWS/Lambda,FunctionName} MetricName=\"Duration\"', 'FunctionName')
    values: cw.Values.fromSearchComponents({
      namespace: 'AWS/Lambda',
      dimensions: ['FunctionName'],
      metricName: 'Duration',
      populateFrom: 'FunctionName',
    }),
    defaultValue: cw.DefaultValue.FIRST,
    visible: true,
  })],
});
```

## Properties

- `defaultValue`: [DefaultValue](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.DefaultValue.html) — Optional default value.

  **Default:** no default value is set

- `id`: string (required) — Unique id.

- `inputType`: [VariableInputType](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.VariableInputType.html) (required) — The way the variable value is selected.

- `label`: string — Optional label in the toolbar.

  **Default:** the variable's value

- `type`: [VariableType](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.VariableType.html) (required) — Type of the variable.

- `value`: string (required) — Pattern or property value to replace.

- `values`: [Values](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Values.html) — Optional values (required for {@link VariableInputType.RADIO} and {@link VariableInputType.SELECT} dashboard variables).

  **Default:** no values

- `visible`: boolean = true — Whether the variable is visible.
