---
title: "Setter"
language: "en"
type: "Symbol"
summary: "Setter[x, val] represents a setter button whose setting x is set to val when the button is clicked. The button is labeled with val, and appears pressed if the value of x is val, and unpressed otherwise. Setter[Dynamic[x], val] takes the setting to be the dynamically updated current value of x, with the value of x being reset if the button is clicked. Setter[x, val, label] labels the setter button with label. Setter[x, {val1, val2, ...}, label] represents a setter button that sets x to valn if multiclicked n times."
keywords: 
- setter
- dynamically setting variables
canonical_url: "https://reference.wolfram.com/language/ref/Setter.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Control Objects"
    link: "https://reference.wolfram.com/language/guide/ControlObjects.en.md"
related_workflows: 
  - 
    title: "Build a Manipulate"
    link: "https://reference.wolfram.com/language/workflow/BuildAManipulate.en.md"
  - 
    title: "Create a Palette"
    link: "https://reference.wolfram.com/language/workflow/CreateAPalette.en.md"
related_functions: 
  - 
    title: "SetterBar"
    link: "https://reference.wolfram.com/language/ref/SetterBar.en.md"
  - 
    title: "RadioButton"
    link: "https://reference.wolfram.com/language/ref/RadioButton.en.md"
  - 
    title: "Checkbox"
    link: "https://reference.wolfram.com/language/ref/Checkbox.en.md"
  - 
    title: "Toggler"
    link: "https://reference.wolfram.com/language/ref/Toggler.en.md"
  - 
    title: "Button"
    link: "https://reference.wolfram.com/language/ref/Button.en.md"
  - 
    title: "PopupMenu"
    link: "https://reference.wolfram.com/language/ref/PopupMenu.en.md"
  - 
    title: "Panel"
    link: "https://reference.wolfram.com/language/ref/Panel.en.md"
  - 
    title: "Set"
    link: "https://reference.wolfram.com/language/ref/Set.en.md"
  - 
    title: "FileNameSetter"
    link: "https://reference.wolfram.com/language/ref/FileNameSetter.en.md"
  - 
    title: "ColorSetter"
    link: "https://reference.wolfram.com/language/ref/ColorSetter.en.md"
  - 
    title: "Trigger"
    link: "https://reference.wolfram.com/language/ref/Trigger.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"
---
# Setter

Setter[x, val] represents a setter button whose setting x is set to val when the button is clicked. The button is labeled with val, and appears pressed if the value of x is val, and unpressed otherwise.

Setter[Dynamic[x], val] takes the setting to be the dynamically updated current value of x, with the value of x being reset if the button is clicked.

Setter[x, val, label] labels the setter button with label.

Setter[x, {val1, val2, …}, label] represents a setter button that sets x to valn if multiclicked n times.

## Details and Options

* ``Setter[x, val]`` takes ``x`` still to be ``val`` even if it is clicked more than once.

* ``Setter[x, {val1, …, valn}, label]`` takes ``x`` still to be ``valn`` if it is multiclicked more than ``n`` times.

* The following options can be given:

|                   |           |                                                                       |
| :---------------- | :-------- | :-------------------------------------------------------------------- |
| Appearance        | Automatic | the overall appearance of the setter                                  |
| AutoAction        | False     | whether to change the setter automatically when the mouse is over it  |
| BaselinePosition  | Automatic | alignment relative to surrounding text                                |
| BaseStyle         | {}        | base style specifications for the setter                              |
| ContentPadding    | True      | whether to shrink the margins tightly around the contents             |
| Enabled           | Automatic | whether the setter is enabled or grayed out                           |
| FrameMargins      | Automatic | margins to leave inside the toggler frame                             |
| ImageMargins      | 0         | margins around the image of the displayed setter                      |
| ImageSize         | All       | the overall image size of the displayed setter                        |

* Typical possible settings for the ``Appearance`` option include ``"Frameless"`` and ``"Palette"``. In some cases, ``"AbuttingLeftRight"``, ``"AbuttingRight"``, etc. are also supported.

* With ``Appearance -> None``, ``label`` is displayed literally, without being placed in a button.

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

---

## Examples (14)

### Basic Examples (1)

A setter with the setting different from its value, showing as unpressed:

```wl
In[1]:= Setter[0, 1]

Out[1]= Setter[0, {1}, "1"]
```

A setter with the setting equal to its value, showing as pressed:

```wl
In[2]:= Setter[1, 1]

Out[2]= Setter[1, {1}, "1"]
```

A setter with the label ``α``, showing unpressed and pressed states:

```wl
In[3]:= {Setter[0, 1, "α"], Setter[1, 1, "α"]}

Out[3]= {Setter[0, {1}, "\"α\""], Setter[1, {1}, "\"α\""]}
```

Dynamically set the value to ``1`` or ``2`` by clicking the respective button:

```wl
In[4]:= {Setter[Dynamic[x], 1], Setter[Dynamic[x], 2]}

Out[4]= {Setter[Dynamic[x], {1}, "1"], Setter[Dynamic[x], {2}, "2"]}
```

### Scope (2)

In this case, single-clicking will return $$1$$`` and double-clicking will return ``$$2$$ :

```wl
In[1]:= {Setter[Dynamic[x], {1, 2}, α], Dynamic[x]}

Out[1]= {Setter[Dynamic[x], {1, 2}, "α"], Dynamic[x]}
```

---

By triple-clicking, this setter will return the setting $$3$$ :

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

Out[1]= {Setter[Dynamic[x], {1, 2, 3}, "α"], Dynamic[x]}
```

### Options (9)

#### Alignment (1)

Align labels in the setter:

```wl
In[1]:= Table[Setter[1, 0, ImageSize -> {30, 30}, Alignment -> a], {a, {Left, Right, Center, Bottom, Top}}]

Out[1]= {Setter[1, {0}, "0", Alignment -> Left, ImageSize -> {30, 30}], Setter[1, {0}, "0", Alignment -> Right, ImageSize -> {30, 30}], Setter[1, {0}, "0", Alignment -> Center, ImageSize -> {30, 30}], Setter[1, {0}, "0", Alignment -> Bottom, ImageSize -> {30, 30}], Setter[1, {0}, "0", Alignment -> Top, ImageSize -> {30, 30}]}
```

All possible alignment positions:

```wl
In[2]:= Table[Setter[1, 0, ImageSize -> {30, 30}, Alignment -> {j, i}], {i, {Top, Center, Bottom}}, {j, {Left, Center, Right}}]//Grid

Out[2]=
|                                                                         |                                                                           |                                                                          |
| ------------------- ... eSize -> {30, 30}] |
| Setter[1, {0}, "0", Alignment -> {Left, Bottom}, ImageSize -> {30, 30}] | Setter[1, {0}, "0", Alignment -> {Center, Bottom}, ImageSize -> {30, 30}] | Setter[1, {0}, "0", Alignment -> {Right, Bottom}, ImageSize -> {30, 30}] |
```

#### Appearance (1)

Change the appearance:

```wl
In[1]:= Table[Setter[0, 1, Appearance -> a], {a, {"Frameless", "Palette"}}]

Out[1]= {Setter[0, {1}, "1", Appearance -> "Frameless"], Setter[0, {1}, "1", Appearance -> "Palette"]}
```

#### AutoAction (1)

By default, ``Setter`` must be clicked to change the setting:

```wl
In[1]:= Setter[0, 1]

Out[1]= Setter[0, {1}, "1"]
```

By setting ``AutoAction -> True``, moving the mouse over the setter changes the setting:

```wl
In[2]:= Setter[0, 1, AutoAction -> True]

Out[2]= Setter[0, {1}, "1", AutoAction -> True]
```

#### Background (1)

Change the background color:

```wl
In[1]:= Table[Setter[1, 0, Background -> a], {a, {Pink, Gray, Yellow, Purple}}]

Out[1]= {Setter[1, {0}, "0", Background -> RGBColor[1, 0.5, 0.5]], Setter[1, {0}, "0", Background -> GrayLevel[0.5]], Setter[1, {0}, "0", Background -> RGBColor[1, 1, 0]], Setter[1, {0}, "0", Background -> RGBColor[0.5, 0, 0.5]]}
```

#### BaselinePosition (1)

Align with surrounding text:

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

Out[1]=
Row[{Setter[0, 1, BaselinePosition -> Top], Setter[0, 1, BaselinePosition -> Center], 
  Setter[0, 1, BaselinePosition -> Bottom]}, "xxx"]
```

#### Enabled (1)

By default, ``Setter`` is enabled:

```wl
In[1]:= {Setter[Dynamic[x], 0], Setter[Dynamic[x], 1]}

Out[1]= {Setter[Dynamic[x], {0}, "0"], Setter[Dynamic[x], {1}, "1"]}
```

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

```wl
In[2]:= {Setter[Dynamic[y], 0, Enabled -> False], Setter[Dynamic[y], 1, Enabled -> False]}

Out[2]= {Setter[Dynamic[y], {0}, "0", Enabled -> False], Setter[Dynamic[y], {1}, "1", Enabled -> False]}
```

#### FrameMargins (1)

Increase the margins from the label to the frame:

```wl
In[1]:= Table[Setter[1, 1, FrameMargins -> m], {m, {0, 10, 20}}]

Out[1]= {Setter[1, {1}, "1", FrameMargins -> 0], Setter[1, {1}, "1", FrameMargins -> 10], Setter[1, {1}, "1", FrameMargins -> 20]}
```

#### ImageMargins (1)

Increase the margins outside the frame:

```wl
In[1]:= Table[Style[Setter[1, 1, ImageMargins -> m], Background -> Black], {m, {0, 10, 20}}]

Out[1]= {Setter[1, {1}, "1", ImageMargins -> 0], Setter[1, {1}, "1", ImageMargins -> 10], Setter[1, {1}, "1", ImageMargins -> 20]}
```

#### ImageSize (1)

Alter the overall image size:

```wl
In[1]:= Grid[Table[Setter[0, 1, ImageSize -> {w, h}], {h, {20, 30, 40}}, {w, {20, 30, 40}}]]

Out[1]=
|                                            |                                            |                                            |
| ------------------------------------------ | ------------------------------------------ | ------------------- ... eSize -> {20, 30}] | Setter[1, {1}, "1", ImageSize -> {30, 30}] | Setter[0, {1}, "1", ImageSize -> {40, 30}] |
| Setter[1, {1}, "1", ImageSize -> {20, 40}] | Setter[0, {1}, "1", ImageSize -> {30, 40}] | Setter[1, {1}, "1", ImageSize -> {40, 40}] |
```

### Applications (1)

Set the size of a graphic:

```wl
In[1]:=
DynamicModule[{x}, 
	Column[{Row[{Setter[Dynamic[x], "Small"], Setter[Dynamic[x], "Medium"]}], Plot[Sin[x], {x, 0, 10}, ImageSize -> Dynamic[x]]}]]

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

### Properties & Relations (1)

``RadioButton`` is a special case of ``Setter`` :

```wl
In[1]:= {RadioButton[Dynamic[x], 0], RadioButton[Dynamic[x], 1]}

Out[1]= {RadioButton[Dynamic[x], {0}], RadioButton[Dynamic[x], {1}]}

In[2]:= {Setter[Dynamic[y], 0], Setter[Dynamic[y], 1]}

Out[2]= {Setter[Dynamic[y], {0}, "0"], Setter[Dynamic[y], {1}, "1"]}
```

## See Also

* [`SetterBar`](https://reference.wolfram.com/language/ref/SetterBar.en.md)
* [`RadioButton`](https://reference.wolfram.com/language/ref/RadioButton.en.md)
* [`Checkbox`](https://reference.wolfram.com/language/ref/Checkbox.en.md)
* [`Toggler`](https://reference.wolfram.com/language/ref/Toggler.en.md)
* [`Button`](https://reference.wolfram.com/language/ref/Button.en.md)
* [`PopupMenu`](https://reference.wolfram.com/language/ref/PopupMenu.en.md)
* [`Panel`](https://reference.wolfram.com/language/ref/Panel.en.md)
* [`Set`](https://reference.wolfram.com/language/ref/Set.en.md)
* [`FileNameSetter`](https://reference.wolfram.com/language/ref/FileNameSetter.en.md)
* [`ColorSetter`](https://reference.wolfram.com/language/ref/ColorSetter.en.md)
* [`Trigger`](https://reference.wolfram.com/language/ref/Trigger.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)

## Related Workflows

* [Build a Manipulate](https://reference.wolfram.com/language/workflow/BuildAManipulate.en.md)
* [Create a Palette](https://reference.wolfram.com/language/workflow/CreateAPalette.en.md)

## History

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