---
title: "CheckboxBar"
language: "en"
type: "Symbol"
summary: "CheckboxBar[x, {val1, val2, ...}] represents a checkbox bar with setting x and with checkboxes for values vali to include in the list x. CheckboxBar[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 checkbox is clicked. CheckboxBar[x, {val1 -> lbl1, val2 -> lbl2, ...}] represents a checkbox bar in which the checkbox associated with value vali has label lbli."
keywords: 
- checkbox
- dynamic control
- multiple selection control
canonical_url: "https://reference.wolfram.com/language/ref/CheckboxBar.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Control Objects"
    link: "https://reference.wolfram.com/language/guide/ControlObjects.en.md"
  - 
    title: "User Interface Structuring & Layout"
    link: "https://reference.wolfram.com/language/guide/UserInterfaceStructuringAndLayout.en.md"
related_workflows: 
  - 
    title: "Programmatically Generate a Report from a Template"
    link: "https://reference.wolfram.com/language/workflow/ProgrammaticallyGenerateAReportFromATemplate.en.md"
related_functions: 
  - 
    title: "TogglerBar"
    link: "https://reference.wolfram.com/language/ref/TogglerBar.en.md"
  - 
    title: "RadioButtonBar"
    link: "https://reference.wolfram.com/language/ref/RadioButtonBar.en.md"
  - 
    title: "Checkbox"
    link: "https://reference.wolfram.com/language/ref/Checkbox.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"
---
# CheckboxBar

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

CheckboxBar[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 checkbox is clicked.

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

## Details and Options

* Multiple checkboxes in a ``CheckboxBar`` can be checked at the same time. The values associated with all checked checkboxes are given in a list. »

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

* In ``CheckboxBar[x, list]``, ``Delimiter`` can appear as an element of ``list``, specifying a vertical delimiter in the displayed setter bar.

* The following options can be given:

|                   |           |                                                     |
| :---------------- | :-------- | :-------------------------------------------------- |
| Appearance        | Automatic | the overall appearance of the checkbox bar          |
| Background        | Automatic | background color to use                             |
| BaselinePosition  | Automatic | alignment relative to surrounding text              |
| BaseStyle         | {}        | base style specifications for each checkbox bar     |
| Enabled           | Automatic | whether the checkbox bar is enabled, or grayed out  |
| ImageMargins      | 0         | margins around the displayed checkbox bar           |

* 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.

* ``Method -> "Active"`` will cause the active area for each item to include the corresponding label.

* The settings for ``BaseStyle`` and ``LabelStyle`` are appended to the default styles typically given by the ``"CheckboxBar"`` and ``"CheckboxBarLabel"`` styles in the current stylesheet.

---

## Examples (17)

### Basic Examples (2)

Create checkboxes with specified states:

```wl
In[1]:= CheckboxBar[{1, 3}, {1, 2, 3}]

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

---

Include labels:

```wl
In[1]:= CheckboxBar[{1, 3}, {1 -> "One", 2 -> "Two", 3 -> "Three"}]

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

### Scope (3)

Use a dynamically updated setting:

```wl
In[1]:= {CheckboxBar[Dynamic[x], {1, 2, 3}], Dynamic[x]}

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

---

Use any expression as a value:

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

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

Out[2]=
{CheckboxBar[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]}
```

---

Separate choices with a ``Delimiter`` :

```wl
In[1]:= CheckboxBar[{1}, {1, 2, Delimiter, 3}]

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

### Options (9)

#### Appearance (4)

Alter the size:

```wl
In[1]:= Table[CheckboxBar[{}, {1, 2, 3}, Appearance -> a], {a, {Tiny, Small, Medium, Large}}]

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

---

Alter the orientation:

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

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

---

Using the ``"Row"`` setting will allow the row of checkboxes to line break:

```wl
In[1]:= CheckboxBar[{}, Range[15], Appearance -> "Row"]

Out[1]= DynamicModule[«3»]

In[2]:= CheckboxBar[{}, Range[15], Appearance -> "Horizontal"]

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

---

Specify a three-column layout with elements ordered vertically:

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

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

#### Background (2)

```wl
In[1]:= Table[CheckboxBar[{}, {1, 3, 5, 7}, Background -> c], {c, {Pink, Green, Gray, Yellow}}]

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

---

Change the background dynamically:

```wl
In[1]:= DynamicModule[{x = {}}, CheckboxBar[Dynamic[x], {0.1, 0.25, 0.3, 0.8}, Background -> Dynamic[Hue[Total[x]]]]]

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

#### BaselinePosition (1)

Align the labels with surrounding text:

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

Out[1]=
Row[{CheckboxBar[{}, {1, 2}, BaselinePosition -> Automatic], 
  CheckboxBar[{}, {1, 2}, BaselinePosition -> Bottom], CheckboxBar[{}, {1, 2}, 
   BaselinePosition -> Center], CheckboxBar[{}, {1, 2}, BaselinePosition -> Top]}, "xxx"]
```

#### Enabled (1)

By default, ``CheckboxBar`` is enabled:

```wl
In[1]:= CheckboxBar[{1, 3}, {1, 2, 3}]

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

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

```wl
In[2]:= CheckboxBar[{1, 3}, {1, 2, 3}, Enabled -> False]

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

#### Method (1)

Normally, toggling the checkbox requires clicking the checkbox directly:

```wl
In[1]:= CheckboxBar[{}, {"long label", "another label"}]

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

With ``Method -> "Active"``, the label can also be clicked to toggle the checkbox:

```wl
In[2]:= CheckboxBar[{}, {"long label", "another label"}, Method -> "Active"]

Out[2]= 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]}
```

---

``CheckboxBar`` is built using ``Checkbox`` and can be used to track a list of values:

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

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

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

Out[2]= {[-], Dynamic[x]}
```

### Possible Issues (1)

Values are added in the order clicked rather than in the order given by the list of possible values:

```wl
In[1]:= {CheckboxBar[Dynamic[x], {1, 2, 3}], Dynamic[x]}

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

## See Also

* [`TogglerBar`](https://reference.wolfram.com/language/ref/TogglerBar.en.md)
* [`RadioButtonBar`](https://reference.wolfram.com/language/ref/RadioButtonBar.en.md)
* [`Checkbox`](https://reference.wolfram.com/language/ref/Checkbox.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)
* [User Interface Structuring & Layout](https://reference.wolfram.com/language/guide/UserInterfaceStructuringAndLayout.en.md)

## Related Workflows

* [Programmatically Generate a Report from a Template](https://reference.wolfram.com/language/workflow/ProgrammaticallyGenerateAReportFromATemplate.en.md)

## History

* [Introduced in 2007 (6.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn60.en.md) \| [Updated in 2008 (7.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn70.en.md)