---
title: "TogglerBar"
language: "en"
type: "Symbol"
summary: "TogglerBar[x, {val1, val2, ...}] represents a toggler bar with setting x and with toggler buttons for values vali to include in the list x. TogglerBar[Dynamic[x], {val1, val2, ...}] takes the setting to be the dynamically updated current value of x, with the values in the list x being reset every time a toggler button is clicked. TogglerBar[x, {val1 -> lbl1, val2 -> lbl2, ...}] represents a toggler bar in which the toggler button associated with value vali has label lbli."
keywords: 
- multiple selection control
canonical_url: "https://reference.wolfram.com/language/ref/TogglerBar.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Control Objects"
    link: "https://reference.wolfram.com/language/guide/ControlObjects.en.md"
  - 
    title: "Creating Inspectors"
    link: "https://reference.wolfram.com/language/guide/CreatingInspectors.en.md"
  - 
    title: "Toolbars"
    link: "https://reference.wolfram.com/language/guide/Toolbars.en.md"
  - 
    title: "User Interface Structuring & Layout"
    link: "https://reference.wolfram.com/language/guide/UserInterfaceStructuringAndLayout.en.md"
related_functions: 
  - 
    title: "CheckboxBar"
    link: "https://reference.wolfram.com/language/ref/CheckboxBar.en.md"
  - 
    title: "SetterBar"
    link: "https://reference.wolfram.com/language/ref/SetterBar.en.md"
  - 
    title: "Toggler"
    link: "https://reference.wolfram.com/language/ref/Toggler.en.md"
  - 
    title: "ListPicker"
    link: "https://reference.wolfram.com/language/ref/ListPicker.en.md"
  - 
    title: "Manipulate"
    link: "https://reference.wolfram.com/language/ref/Manipulate.en.md"
  - 
    title: "Control"
    link: "https://reference.wolfram.com/language/ref/Control.en.md"
  - 
    title: "AnySubset"
    link: "https://reference.wolfram.com/language/ref/AnySubset.en.md"
related_tutorials: 
  - 
    title: "Introduction to Dynamic"
    link: "https://reference.wolfram.com/language/tutorial/IntroductionToDynamic.en.md"
  - 
    title: "Introduction to Control Objects"
    link: "https://reference.wolfram.com/language/tutorial/IntroductionToControlObjects.en.md"
  - 
    title: "Generalized Input"
    link: "https://reference.wolfram.com/language/tutorial/GeneralizedInput.en.md"
---
# TogglerBar

TogglerBar[x, {val1, val2, …}] represents a toggler bar with setting x and with toggler buttons for values vali to include in the list x.

TogglerBar[Dynamic[x], {val1, val2, …}] takes the setting to be the dynamically updated current value of x, with the values in the list x being reset every time a toggler button is clicked.

TogglerBar[x, {val1 -> lbl1, val2 -> lbl2, …}] represents a toggler bar in which the toggler button associated with value vali has label lbli.

## Details and Options

* Multiple toggler buttons in a ``TogglerBar`` can be depressed at the same time. The values associated with all depressed buttons are given in a list.

* The ``vali`` and ``lbli`` can be strings, boxes, graphics or any other expressions, including dynamic expressions. »

* The following options can be given:

|                   |           |                                                    |
| :---------------- | :-------- | :------------------------------------------------- |
| Appearance        | Automatic | the overall appearance of the toggler bar          |
| BaselinePosition  | Automatic | alignment relative to surrounding text             |
| BaseStyle         | {}        | base style specifications for the toggler bar      |
| Enabled           | Automatic | whether the toggler bar is enabled, or grayed out  |

* Possible settings for the ``Appearance`` option include:

|              |                                           |
| ------------ | ----------------------------------------- |
| "Horizontal" | equally spaced horizontally               |
| "Vertical"   | equally spaced vertically                 |
| "Row"        | laid out like text, allowing linewrapping |

* ``Appearance -> "Vertical" -> {h, w}`` will display the controls in a grid with the specified number of columns and rows, vertically filling each column in turn. ``Appearance -> "Horizontal" -> {h, w}`` horizontally fills the rows instead.

* If one of ``h`` or ``w`` is ``Automatic``, it is taken to be the smallest number so that all the controls will fit in the resulting grid. If both ``h`` and ``w`` are ``Automatic``, they are calculated so the grid has roughly the same number of rows as columns.

* The settings for ``BaseStyle`` are appended to the default style typically given by the ``"TogglerBar"`` style in the current stylesheet.

---

## Examples (13)

### Basic Examples (2)

Create togglers with a specified state:

```wl
In[1]:= TogglerBar[{2, 5}, Range[5]]

Out[1]= DynamicModule[«3»]
```

---

Dynamically change the value of $x$ :

```wl
In[1]:= {TogglerBar[Dynamic[x], Range[5]], Dynamic[x]}

Out[1]= {TogglerBar[Dynamic[x], {1, 2, 3, 4, 5}], Dynamic[x]}
```

### Scope (2)

Include labels:

```wl
In[1]:= TogglerBar[{1}, {1 -> " I ", 2 -> " II ", 3 -> " III "}]

Out[1]= DynamicModule[«3»]
```

---

Values and labels can be any expression:

```wl
In[1]:=
g = Plot[Sin[x], {x, 0, 2π}, Axes -> False, ImageSize -> 40];
f = Sqrt[y]Tan[α y - β];
s = "αβγ";

In[2]:= {TogglerBar[Dynamic[x], {g, f, s}], Dynamic[x]}

Out[2]=
{TogglerBar[Dynamic[x], 
 {Graphics[{{{}, {}, {Hue[0.67, 0.6, 0.6], Line[CompressedData["«9213»"]]}}}, 
   {AspectRatio -> GoldenRatio^(-1), AxesOrigin -> {0, 0}, ImageSize -> 40, 
    PlotRange -> {{0, 2*Pi}, {-0.9999998592131705, 0.9999998782112116}}, PlotRangeClipping -> True, 
    PlotRangePadding -> {Scaled[0.02], Scaled[0.02]}}], Sqrt[y]*Tan[y*α - β], "αβγ"}], Dynamic[x]}
```

### Options (6)

#### Appearance (3)

Set the orientation:

```wl
In[1]:= Table[TogglerBar[{}, Range[3], Appearance -> a], {a, {"Horizontal", "Vertical"}}]

Out[1]= {DynamicModule[«3»], DynamicModule[«3»]}
```

---

``"Row"`` allows linewrapping while ``"Horizontal"`` does not:

```wl
In[1]:= TogglerBar[{}, Range[30], Appearance -> "Horizontal"]

Out[1]= DynamicModule[«3»]

In[2]:= TogglerBar[{}, Range[30], Appearance -> "Row"]

Out[2]= DynamicModule[«3»]
```

---

Specify a three-column layout, with elements ordered vertically:

```wl
In[1]:= TogglerBar[Dynamic[props], CityData["Properties"], Appearance -> "Vertical" -> {Automatic, 3}]

Out[1]=
TogglerBar[Dynamic[props], {"AlternateNames", "Coordinates", "Country", "Elevation", "FullName", 
  "Latitude", "LocationLink", "Longitude", "Name", "Population", "Region", "RegionName", 
  "StandardName", "TimeZone"}, Appearance -> "Vertical" -> {Automatic, 3}]
```

#### BaselinePosition (1)

Align with surrounding text:

```wl
In[1]:= Row[Table[TogglerBar[{2, 5}, Range[5], BaselinePosition -> p], {p, {Top, Center, Bottom}}], "xxx"]

Out[1]=
Row[{TogglerBar[{2, 5}, {1, 2, 3, 4, 5}, BaselinePosition -> Top], 
  TogglerBar[{2, 5}, {1, 2, 3, 4, 5}, BaselinePosition -> Center], 
  TogglerBar[{2, 5}, {1, 2, 3, 4, 5}, BaselinePosition -> Bottom]}, "xxx"]
```

#### Enabled (2)

By default, ``TogglerBar`` is enabled:

```wl
In[1]:= TogglerBar[{}, Range[5]]

Out[1]= DynamicModule[«3»]
```

---

By setting ``Enabled -> False``, the toggler bar is disabled but visible in its current state:

```wl
In[1]:= TogglerBar[{2, 5}, Range[5], Enabled -> False]

Out[1]= DynamicModule[«3»]
```

### Applications (1)

Select what harmonics to show:

```wl
In[1]:=
DynamicModule[{x = {Graphics[{}, ImageSize -> 100, AspectRatio -> 1 / GoldenRatio]}, g = Table[Plot[Sin[n x], {x, 0, 2π}, ImageSize -> 100, Ticks -> None], {n, 3}]}, 
	{TogglerBar[Dynamic[x], g], Dynamic[Show[x]]}
	]

Out[1]= DynamicModule[«3»]
```

### Properties & Relations (2)

``CheckboxBar`` is a special case of ``TogglerBar`` :

```wl
In[1]:= {CheckboxBar[Dynamic[x], Range[5]], Dynamic[x]}

Out[1]= {CheckboxBar[Dynamic[x], {1, 2, 3, 4, 5}], Dynamic[x]}

In[2]:= {TogglerBar[Dynamic[y], Range[5]], Dynamic[y]}

Out[2]= {TogglerBar[Dynamic[y], {1, 2, 3, 4, 5}], Dynamic[y]}
```

---

``TogglerBar`` is built using ``Toggler`` and can be used to track a list of values:

```wl
In[1]:= {TogglerBar[Dynamic[x], Range[5]], Dynamic[x]}

Out[1]= {TogglerBar[Dynamic[x], {1, 2, 3, 4, 5}], Dynamic[x]}

In[2]:= {Toggler[Dynamic[y]], Dynamic[y]}

Out[2]=
{Toggler[Dynamic[y], {True -> "True", False -> "False"}, 
 DynamicBox[ToBoxes[y, StandardForm], 
  ImageSizeCache -> {28.8, {0.14400000000000002, 7.872}}]], Dynamic[y]}
```

## See Also

* [`CheckboxBar`](https://reference.wolfram.com/language/ref/CheckboxBar.en.md)
* [`SetterBar`](https://reference.wolfram.com/language/ref/SetterBar.en.md)
* [`Toggler`](https://reference.wolfram.com/language/ref/Toggler.en.md)
* [`ListPicker`](https://reference.wolfram.com/language/ref/ListPicker.en.md)
* [`Manipulate`](https://reference.wolfram.com/language/ref/Manipulate.en.md)
* [`Control`](https://reference.wolfram.com/language/ref/Control.en.md)
* [`AnySubset`](https://reference.wolfram.com/language/ref/AnySubset.en.md)

## Tech Notes

* [Introduction to Dynamic](https://reference.wolfram.com/language/tutorial/IntroductionToDynamic.en.md)
* [Introduction to Control Objects](https://reference.wolfram.com/language/tutorial/IntroductionToControlObjects.en.md)
* [Generalized Input](https://reference.wolfram.com/language/tutorial/GeneralizedInput.en.md)

## Related Guides

* [Control Objects](https://reference.wolfram.com/language/guide/ControlObjects.en.md)
* [Creating Inspectors](https://reference.wolfram.com/language/guide/CreatingInspectors.en.md)
* [`Toolbars`](https://reference.wolfram.com/language/guide/Toolbars.en.md)
* [User Interface Structuring & Layout](https://reference.wolfram.com/language/guide/UserInterfaceStructuringAndLayout.en.md)

## History

* [Introduced in 2007 (6.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn60.en.md)