represents a button that is labeled with label, and evaluates action whenever it is clicked.

Details and Options

  • label can be any expression, including a dynamic one. »
  • Button by default displays label in "Button" style, which typically uses the system button font.
  • Button[label,action] maintains action in unevaluated form, evaluating it each time the button is clicked.
  • The following options can be given:
  • AlignmentAutomatichow to align contents within the button
    AppearanceAutomaticthe overall appearance of the button
    AutoActionFalsewhether to click the button automatically when the mouse is over it
    BackgroundAutomaticbutton background color
    BaselinePositionAutomaticalignment relative to surrounding text
    BaseStyle"GenericButton"base style specifications for the button
    ContentPaddingTruewhether to shrink the margins tightly around the contents
    EnabledAutomaticwhether the button is enabled or grayed out
    EvaluatorAutomaticthe kernel in which to evaluate expr
    FrameMarginsAutomaticminimum margins to leave inside the frame
    ImageMargins0margins around the image of the displayed button
    ImageSizeFullthe overall image size of the displayed button
    Method"Preemptive"the evaluation method to use
    TooltipNonethe tooltip for the button
    TooltipDelay0.`how long to delay before displaying the tooltip
    TooltipStyle{}style specifications for the tooltip
  • With the default setting ImageSize->Full, a button will be sized to fill out its enclosing region in a Grid or related construct.
  • The setting ImageSize->Automatic specifies that the button will be sized to fit its contents, but will not expand to fill out an enclosing region.
  • Settings of Tiny, Small, Medium, and Large for ImageSize specify buttons with certain system-standard minimum sizes.
  • Typical possible settings for the Appearance option include "DialogBox", "Frameless", "Palette", and "FramedPalette". In some cases, "AbuttingLeftRight", "AbuttingRight", etc. are also supported.
  • Appearance->"Pressed" gives a button with a pressed appearance. Appearance->{type,"Pressed"} gives a button of a certain type with a pressed appearance.
  • With Appearance->None, label is displayed literally, without being placed in a button. »
  • Typical possible settings for the Method option include "Preemptive" and "Queued".
  • With the default setting Method->"Preemptive", button actions are performed immediately, preempting any other evaluation, but are allocated only a limited time to complete.
  • With the setting Method->"Queued", button actions are added to the current queue of evaluations, and are performed when other evaluations are complete. No time limit is applied.
  • The settings for BaseStyle are appended to the default style typically given by the "Button" style in the current stylesheet.
  • Button[label] displays as a button labeled with label, but performs no action.
  • Button[prims,action] can be used within graphics objects to specify that action should be evaluated whenever the graphics primitives prims are clicked. »
  • Button[label,None,BaseStyle->stylename] inherits button functionality from the definition of stylename in the stylesheet. Such styles typically allow \[SelectionPlaceholder] to be used in label to represent the currently selected text.
  • Some style names defined in default stylesheets that provide Button functionality:
  • "Paste"effectively use NotebookApply upon the current selection using the button label as the applied data
    "Evaluate"use NotebookApply and SelectionEvaluate in sequence upon the current selection
    "EvaluateCell"use NotebookApply upon the current selection, then evaluate the entire cell containing the selection
    "CopyEvaluate"equivalent to "Evaluate", but paste the result into a new cell instead of changing the currently selected cell
    "CopyEvaluateCell"equivalent to "EvaluateCell", but apply changes to a newly created copy of the input cell instead of changing the currently selected cell


open allclose all

Basic Examples  (1)

Create a button that prints a number:

Click for copyable input

Scope  (7)

Generalizations & Extensions  (2)

Options  (27)

Applications  (5)

Properties & Relations  (2)

Possible Issues  (4)

Neat Examples  (3)

See Also

DefaultButton  CancelButton  PasteButton  Hyperlink  ButtonBar  ActionMenu  Setter  RadioButton  Panel  Dynamic  Input  ButtonNotebook  DialogReturn  PopupWindow  ClickPane  Trigger  EmitSound  Speak


Introduced in 2007
| Updated in 2010