Dynamic
✖
Dynamic
represents an object that displays as the dynamically updated current value of expr. If the displayed form of Dynamic[expr] is interactively changed or edited, an assignment expr=val is done to give expr the new value val that corresponds to the displayed form.
also evaluates fend[val,expr] when interactive changing or editing is complete.
also evaluates fstart[val,expr] when interactive changing or editing begins.
Details and Options




- Dynamic[expr] can appear not only directly as an expression to display, but also for example as a coordinate in a graphics primitive or an object such as a slider, or as a setting for an option.
- When used to assign values to expr through interactive operations, the expression in Dynamic[expr] will most often be a symbol x, an object x[i], a part e[[i]], or a list {x,y,…}.
- In graphics, for example, Point[Dynamic[{x,y}]] represents a point whose position is dynamically updated to be given by the current values of x and y. Whenever the point is interactively moved, assignments of the form {x,y}={valx,valy} are done. Point[Dynamic[{x,y}]] can be moved interactively; Dynamic[Point[{x,y}]] cannot.
- Dynamic[expr] evaluates expr whenever it needs its value and it determines that any type of value of symbols on which it depends might have changed.
- If Refresh or Clock objects appear in the evaluation of the expression in Dynamic[expr], then expr will always continually be reevaluated.
- Dynamic has attribute HoldFirst, so that expr is not evaluated until its value is needed for display.
- Dynamic[expr] is equivalent to Dynamic[expr,(expr=#)&].
- Dynamic[expr,f] makes interactive operations not change expr except by virtue of the evaluation of f[val,expr].
- Objects represented by Dynamic[expr,None] cannot be changed interactively, but will change if the value of expr changes for other reasons.
- Dynamic[expr,Temporary] allows the displayed form of an object to change in the course of interactive operations, but assigns an updated value to expr only when the operations are complete.
- For interactive mouse operations, Dynamic[expr,{fstart,f,fend}] typically evaluates fstart[val,expr] once when the mouse is pressed, then evaluates f[val,expr] whenever the mouse is moved, and then evaluates fend[val,expr] once when the mouse is released.
- If the mouse is not moved, fstart, f, and fend are each evaluated exactly once.
- f[val,expr] is always evaluated once immediately after the evaluation of fstart[val,expr], and when it is last evaluated, the value of val is always the same as in fend[val,expr].
- Interactive operations that can affect Dynamic objects include dragging of elements in graphics or in objects such as Slider, as well as editing of fields in objects such as InputField.
- The functions fstart, f, and fend can be the following:
-
Automatic assign values using Set None perform no action Temporary allow interactive operations to make temporary changes func evaluate func[val,expr] - Dynamic[expr,f] is equivalent to Dynamic[expr,{None,f,None}].
- Dynamic[expr,Temporary] is equivalent to Dynamic[expr,{None,Temporary,Automatic}].
- Dynamic[expr,f] can be used to enforce constraints on values assigned to expr.
- Dynamic[expr,f] can be used to do assignments for individual variables when expr is an expression like x+y.
- A function func[val,expr] should have attribute HoldRest if it is going to perform an assignment to expr. This can be achieved with Function[{v,e},body,HoldRest].
- The following options can be given:
-
BaseStyle {} base style specifications for the displayed object Deinitialization None an expression to evaluate when the Dynamic can no longer be displayed Evaluator Automatic the kernel to use for evaluations Initialization None an expression to evaluate when the Dynamic is first displayed ShrinkingDelay 0. how long to delay before shrinking if the displayed object gets smaller SynchronousUpdating True whether to evaluate contents synchronously TrackedSymbols All symbols whose changes trigger an update UpdateInterval Infinity time interval at which to do updates - Dynamic[e] displays as the dynamically updated current value of e in StandardForm and TraditionalForm, but just as Dynamic[e] in InputForm and OutputForm.
- Dynamic[expr] provides an analog of delayed assignment, where values are implicitly requested by the need to display, rather than by evaluation of an expression.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Dynamic simply returns the current value of its argument:

https://wolfram.com/xid/0mrdma-cp2a8f

Assign a value to to update the output above:

https://wolfram.com/xid/0mrdma-egto16

Tie the symbol to a Slider:

https://wolfram.com/xid/0mrdma-imk66i

Scope (24)Survey of the scope of standard use cases
Basic Dynamic (6)
Any expression can be wrapped with Dynamic:

https://wolfram.com/xid/0mrdma-d0sqfe

Dynamic is not shown in StandardForm, but is still present:

https://wolfram.com/xid/0mrdma-d6hoy4

Use Dynamic to link the currently displayed value depending on :

https://wolfram.com/xid/0mrdma-615ryl


https://wolfram.com/xid/0mrdma-lmmzzi


https://wolfram.com/xid/0mrdma-5f2070


https://wolfram.com/xid/0mrdma-2q9y1g


https://wolfram.com/xid/0mrdma-256w2p

By default, variables inside Dynamic are not localized:

https://wolfram.com/xid/0mrdma-wns1lv

Use DynamicModule to localize variables:

https://wolfram.com/xid/0mrdma-w3xs5m


https://wolfram.com/xid/0mrdma-z5uu6l

A Dynamic expression can be self-triggering:

https://wolfram.com/xid/0mrdma-lgmr9y

Use with Slider:

https://wolfram.com/xid/0mrdma-p3qs1d

Expressions such as RandomReal and DateString do not automatically update:

https://wolfram.com/xid/0mrdma-qp18n1


https://wolfram.com/xid/0mrdma-dajf7h

Use UpdateInterval to force dynamic updating:

https://wolfram.com/xid/0mrdma-cce67d


https://wolfram.com/xid/0mrdma-gl615s

Dynamic holds its argument and never evaluates it unless it displays as output:

https://wolfram.com/xid/0mrdma-mvhwc9
Since the above Dynamic was never displayed, the assignment was never executed:

https://wolfram.com/xid/0mrdma-bk4u5i

Placing Dynamic (3)
Plot needs specific numerical values to create the output:

https://wolfram.com/xid/0mrdma-hfnpry


https://wolfram.com/xid/0mrdma-izckjh

Separate Dynamic expressions update independently, allowing for efficiency:

https://wolfram.com/xid/0mrdma-y6gyx7

https://wolfram.com/xid/0mrdma-dckwju


https://wolfram.com/xid/0mrdma-whv6kh

Use graphics coordinates as control input by placing Dynamic around them:

https://wolfram.com/xid/0mrdma-ei91r7

Use the graphics coordinates as control input and see the effects on 2D sliders:

https://wolfram.com/xid/0mrdma-lisf83

Interactive Dynamic (8)
Use Dynamic to connect variables with interactive controls, such as Slider:

https://wolfram.com/xid/0mrdma-g14irb


https://wolfram.com/xid/0mrdma-u9g39n


https://wolfram.com/xid/0mrdma-mlz4xm


https://wolfram.com/xid/0mrdma-7j8swp


https://wolfram.com/xid/0mrdma-wndx6k


https://wolfram.com/xid/0mrdma-rmk19f

Use Dynamic to control view elements, such as TabView:

https://wolfram.com/xid/0mrdma-g5sc0r


https://wolfram.com/xid/0mrdma-jipojg


https://wolfram.com/xid/0mrdma-fzvxy


https://wolfram.com/xid/0mrdma-lp81ca


https://wolfram.com/xid/0mrdma-r7tiru

Use Dynamic to set a front end option, such as ImageSize:

https://wolfram.com/xid/0mrdma-b8ftef

Advanced Dynamic (7)
By default, Dynamic performs an assignment operation when used in an interactive element:

https://wolfram.com/xid/0mrdma-0f3t4u


https://wolfram.com/xid/0mrdma-sigivm


https://wolfram.com/xid/0mrdma-e7a0mp

Use the second argument to specify a function to be evaluated during interaction:

https://wolfram.com/xid/0mrdma-bhphjr

Supply a list of two functions to be evaluated during and after interaction:

https://wolfram.com/xid/0mrdma-21ohvi

Supply a list of three functions to be evaluated before, during, and after interaction:

https://wolfram.com/xid/0mrdma-ncr2j2

Use Temporary to update the dynamic variable at the end of interaction:

https://wolfram.com/xid/0mrdma-5r90se

Use None to disallow updating the dynamic variable:

https://wolfram.com/xid/0mrdma-h2eg00

Dynamic also performs assignment operations for interactively settable front end options:

https://wolfram.com/xid/0mrdma-ezxbrl

Options (8)Common values & functionality for each option
Deinitialization (1)
Evaluator (1)
Specify a Dynamic that will only run in the kernel named "Local":

https://wolfram.com/xid/0mrdma-8o5qyf

Initialization (2)
By default, external definitions are lost between kernel sessions:

https://wolfram.com/xid/0mrdma-fgp9g3

https://wolfram.com/xid/0mrdma-bmdhst

Use Initialization to evaluate expressions necessary for displaying the output:

https://wolfram.com/xid/0mrdma-04g9jo

ShrinkingDelay (1)
Assign a number or graphics to :

https://wolfram.com/xid/0mrdma-p5g02x

Use ShrinkingDelay to allow lapse time before shrinking the size of the output:

https://wolfram.com/xid/0mrdma-rd62w0

SynchronousUpdating (1)
Applications (5)Sample problems that can be solved with this function
Constrain the coordinates of a point to lie on a circle:

https://wolfram.com/xid/0mrdma-l1va85

Construct a dynamic calculating interface:

https://wolfram.com/xid/0mrdma-dv1

Create a timer to track lapsed minutes and seconds, with Trigger for the controls:

https://wolfram.com/xid/0mrdma-hmct2

Create a simple interface that looks up the shapes of countries:

https://wolfram.com/xid/0mrdma-e10gc0

Construct custom controls, e.g. an angular slider with range :

https://wolfram.com/xid/0mrdma-lnuxzl

An angular slider with range :

https://wolfram.com/xid/0mrdma-sk4vsb

Properties & Relations (4)Properties of the function, and connections to other functions
Dynamic may be used to directly display its contents:

https://wolfram.com/xid/0mrdma-bzyczz

A Dynamic that simply displays has no interactivity, and the second argument does not affect it:

https://wolfram.com/xid/0mrdma-blb6xg

Alternatively, Dynamic may be fed as a value to an interactive control, object or option:

https://wolfram.com/xid/0mrdma-rp89i

A value-style Dynamic invokes its second argument when the value is interactively changed:

https://wolfram.com/xid/0mrdma-ny8sx

Dynamic expressions do not evaluate their contents until the result is displayed onscreen:

https://wolfram.com/xid/0mrdma-3vzgrq
Even showing the result is not a guarantee that it will resolve immediately:

https://wolfram.com/xid/0mrdma-sdzijg

Use FinishDynamic when timing is important:

https://wolfram.com/xid/0mrdma-rrrcgn

Synchronous dynamics are time-limited according to the value of DynamicEvaluationTimeout:

https://wolfram.com/xid/0mrdma-xzyiyv

An evaluation can detect if it's being dynamically evaluated by using $DynamicEvaluation:

https://wolfram.com/xid/0mrdma-se52fy

Possible Issues (4)Common pitfalls and unexpected behavior
The following example does not work because the assignment operation fails:

https://wolfram.com/xid/0mrdma-7a20bz

Use the second argument of Dynamic to control the assignment operation:

https://wolfram.com/xid/0mrdma-yeu4ug

Self-triggering Dynamic can easily cause infinite loops (delete the output to stop it):

https://wolfram.com/xid/0mrdma-ufr6lq
By default, view elements generate the entire contents before displaying:

https://wolfram.com/xid/0mrdma-d5ja6f

Use Dynamic and ImageSize->Automatic to generate the contents only when displayed:

https://wolfram.com/xid/0mrdma-rqjwor

Module variables are not initialized, and returning a Module variable leaks the symbol name:

https://wolfram.com/xid/0mrdma-dnsaz2

Generally, variables should be initialized and localized using DynamicModule instead:

https://wolfram.com/xid/0mrdma-jhc5lc

It is also acceptable to wrap Dynamic entirely around a Module:

https://wolfram.com/xid/0mrdma-hwl4m9

Neat Examples (6)Surprising or curious use cases
Coupled Slider:

https://wolfram.com/xid/0mrdma-nj1dzk

Coupled Slider2D:

https://wolfram.com/xid/0mrdma-iuthrj

A "droopy" Slider:

https://wolfram.com/xid/0mrdma-va58uu

Center a disk at the mouse position as it moves over the graphics area:

https://wolfram.com/xid/0mrdma-p48mbv

Remember the last mouse position as it leaves the graphics area:

https://wolfram.com/xid/0mrdma-hy5sqh

Click inside the framed area to see bouncing balls:

https://wolfram.com/xid/0mrdma-89yysa

Wolfram Research (2007), Dynamic, Wolfram Language function, https://reference.wolfram.com/language/ref/Dynamic.html.
Text
Wolfram Research (2007), Dynamic, Wolfram Language function, https://reference.wolfram.com/language/ref/Dynamic.html.
Wolfram Research (2007), Dynamic, Wolfram Language function, https://reference.wolfram.com/language/ref/Dynamic.html.
CMS
Wolfram Language. 2007. "Dynamic." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Dynamic.html.
Wolfram Language. 2007. "Dynamic." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Dynamic.html.
APA
Wolfram Language. (2007). Dynamic. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Dynamic.html
Wolfram Language. (2007). Dynamic. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Dynamic.html
BibTeX
@misc{reference.wolfram_2025_dynamic, author="Wolfram Research", title="{Dynamic}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Dynamic.html}", note=[Accessed: 08-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_dynamic, organization={Wolfram Research}, title={Dynamic}, year={2007}, url={https://reference.wolfram.com/language/ref/Dynamic.html}, note=[Accessed: 08-June-2025
]}