Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • System Modeler

    Multidomain modeling and simulation of complex systems

  • Compute ServicesUse with Mathematica and Wolfram|One
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Wolfram|Alpha

  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs

AI Products

  • Wolfram AI Ecosystem
  • Wolfram Foundation Tool
  • Wolfram Cloud MCP
  • Wolfram Local MCP
  • Agent One API
  • CAG Component APIs

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • Linguistic Understanding

Additional Deployment Options

  • Wolfram Cloud
  • Wolfram Web Engine
  • wolframscript
  • WSTPServer
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

Wolfram Consulting

Data Science, Finance & Business

  • Artificial Intelligence
  • Data Science
  • Healthcare
  • Real Estate

Engineering

  • Civil Engineering
  • Automotive Engineering
  • Sustainable Energy

Science & Technology

  • AgTech
  • Biosciences
  • Environmental Science
  • Food Science
  • Quantum Computation
  • Social and Behavioral Sciences

More Wolfram Solutions

Technology for Education

  • Research Universities
  • Colleges & Teaching Universities
  • High Schools
  • Resources for Students

Education Initiatives

  • Next-Gen EdTech
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
For AIs
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • System Modeler
    • Compute ServicesUse with Mathematica and Wolfram|One
    • AI AccessUse with Mathematica and Wolfram|One
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Wolfram|Alpha
      • Wolfram|Alpha Website
      • Wolfram|Alpha APIs
    • AI Products
      • Wolfram AI Ecosystem
      • Wolfram Foundation Tool
      • Wolfram Cloud MCP
      • Wolfram Local MCP
      • Agent One API
      • CAG Component APIs
    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • Linguistic Understanding
    • Additional Deployment Options
      • Wolfram Cloud
      • Wolfram Web Engine
      • wolframscript
      • WSTPServer
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions
    • Wolfram Consulting

    Data Science, Finance & Business

    • Artificial Intelligence
    • Data Science
    • Healthcare
    • Real Estate

    Engineering

    • Civil Engineering
    • Automotive Engineering
    • Sustainable Energy

    Science & Technology

    • AgTech
    • Biosciences
    • Environmental Science
    • Food Science
    • Quantum Computation
    • Social and Behavioral Sciences

    More Wolfram Solutions

    Technology for Education

    • Research Universities
    • Colleges & Teaching Universities
    • High Schools
    • Resources for Students

    Education Initiatives

    • Next-Gen EdTech
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • For AIs
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
DynamicModule
  • See Also
    • Dynamic
    • Module
    • Manipulate
    • LocalizeVariables
    • Interpretation
  • Related Guides
    • Dynamic Interactivity Language
    • Scoping Constructs
    • Low-Level Interface Control
    • Custom Interface Construction
    • Package Development
    • Click-Interactive Panels
    • Control Objects
    • Setting Up User Interactions
  • Workflows
    • Put Autoupdating Dynamic Content in a Notebook
    • Use Locator Controls
  • Tech Notes
    • Introduction to Dynamic
    • Advanced Dynamic Functionality
    • DynamicModule Scoping
    • See Also
      • Dynamic
      • Module
      • Manipulate
      • LocalizeVariables
      • Interpretation
    • Related Guides
      • Dynamic Interactivity Language
      • Scoping Constructs
      • Low-Level Interface Control
      • Custom Interface Construction
      • Package Development
      • Click-Interactive Panels
      • Control Objects
      • Setting Up User Interactions
    • Workflows
      • Put Autoupdating Dynamic Content in a Notebook
      • Use Locator Controls
    • Tech Notes
      • Introduction to Dynamic
      • Advanced Dynamic Functionality
      • DynamicModule Scoping

DynamicModule[{x,y,…},expr]

represents an object which maintains the same local instance of the symbols x, y, … in the course of all evaluations of Dynamic objects in expr. Symbols specified in a DynamicModule will by default have their values maintained even across Wolfram System sessions.

DynamicModule[{x=x0,y=y0,…},expr]

specifies initial values for x, y, ….

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
DynamicModule Variables  
DynamicModule State  
Generalizations & Extensions  
Options  
BaseStyle  
Deinitialization  
DynamicModuleValues  
Show More Show More
ExcludedContexts  
InheritScope  
Initialization  
IncludedContexts  
SaveDefinitions  
SynchronousInitialization  
UndoTrackedVariables  
UnsavedVariables  
Applications  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Tech Notes
Related Guides
Related Workflows
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • Dynamic
    • Module
    • Manipulate
    • LocalizeVariables
    • Interpretation
  • Related Guides
    • Dynamic Interactivity Language
    • Scoping Constructs
    • Low-Level Interface Control
    • Custom Interface Construction
    • Package Development
    • Click-Interactive Panels
    • Control Objects
    • Setting Up User Interactions
  • Workflows
    • Put Autoupdating Dynamic Content in a Notebook
    • Use Locator Controls
  • Tech Notes
    • Introduction to Dynamic
    • Advanced Dynamic Functionality
    • DynamicModule Scoping
    • See Also
      • Dynamic
      • Module
      • Manipulate
      • LocalizeVariables
      • Interpretation
    • Related Guides
      • Dynamic Interactivity Language
      • Scoping Constructs
      • Low-Level Interface Control
      • Custom Interface Construction
      • Package Development
      • Click-Interactive Panels
      • Control Objects
      • Setting Up User Interactions
    • Workflows
      • Put Autoupdating Dynamic Content in a Notebook
      • Use Locator Controls
    • Tech Notes
      • Introduction to Dynamic
      • Advanced Dynamic Functionality
      • DynamicModule Scoping

DynamicModule

DynamicModule[{x,y,…},expr]

represents an object which maintains the same local instance of the symbols x, y, … in the course of all evaluations of Dynamic objects in expr. Symbols specified in a DynamicModule will by default have their values maintained even across Wolfram System sessions.

DynamicModule[{x=x0,y=y0,…},expr]

specifies initial values for x, y, ….

Details and Options

  • DynamicModule first gives unique names to local variables in expr, just like Module, then evaluates the resulting expression, and then returns a version of this wrapped in DynamicModule.
  • In a notebook, this returned version will often be displayed in an output cell. An example is the output from Manipulate.
  • If interactive changing or editing of Dynamic objects within the displayed form of a DynamicModule results in changes in any values for local variables, then the DynamicModule object is modified to reflect these.
  • Values of local variables in a DynamicModule are by default automatically saved when a notebook containing the DynamicModule is saved, so that these values in effect persist across sessions of the Wolfram System.
  • If you make a copy of a piece of a notebook that contains a DynamicModule object, the local variables in the copy will be independent of the local variables in the original, though they will start with the same values.
  • The following options can be given:
  • BaseStyle {}base style specifications for the displayed object
    Deinitialization Nonean expression to evaluate when the DynamicModule can no longer be displayed
    DynamicModuleValues Automaticdynamically updated data on variable values
    ExcludedContexts Automaticcontexts excluded from SaveDefinitions
    InheritScope Falseconnect DynamicModule variables to another DynamicModule instance
    IncludedContexts Allcontexts considered for SaveDefinitions
    Initialization Nonean expression to evaluate when the DynamicModule is first displayed
    SaveDefinitions Falsewhether to save all definitions related to expr
    SynchronousInitialization Truewhether to perform initialization synchronously
    UndoTrackedVariables Nonevariables which, when changed, should be tracked by the front end's undo mechanism
    UnsavedVariables Nonevariables whose values should not be saved
  • When DynamicModule is first evaluated, initial assignments for local variables are made during the evaluation. Any setting for the Initialization option is evaluated only when the output of DynamicModule is displayed.
  • When a DynamicModule object is displayed for the first time in a particular notebook, saved values for local variables are restored, and then any setting for the Initialization option is evaluated.
  • All values of local variables are saved, except for those included in the UnsavedVariables list. Ordinary values of symbols are saved in the first argument of the DynamicModule; other values are saved in the setting for the DynamicModuleValues option.
  • DynamicModule has attribute HoldAll.
  • DynamicModule constructs can be nested in any way, with inner variables being renamed if necessary.
  • DynamicModule is a scoping construct that implements lexical scoping.

Examples

open all close all

Basic Examples  (1)

Create a Slider with a dynamically updating localized variable:

Wolfram Language code: DynamicModule[{x}, {Slider[Dynamic[x]], Dynamic[x]}]

Copy and paste the output above to get a standalone object:

Scope  (6)

DynamicModule Variables  (3)

Use DynamicModule to localize variables and prevent conflicts with their global counterparts:

Wolfram Language code: {Slider[Dynamic[x]], Dynamic[x]}
Wolfram Language code: DynamicModule[{x}, {Slider[Dynamic[x]], Dynamic[x]}]

Local variables are unique to the generated output:

Wolfram Language code: {Slider[Dynamic[x]], Dynamic[x]}
Wolfram Language code: %
Wolfram Language code: DynamicModule[{x}, {Slider[Dynamic[x]], Dynamic[x]}]
Wolfram Language code: %

Assign initial values to local variables, just like Module:

Wolfram Language code: DynamicModule[{a = 3, b = 2, c = 1}, {a, b, c}.x ^ Range[3]]

Define a function as a local variable:

Wolfram Language code: DynamicModule[{f, p}, f[g_] := Graphics[g, ImageSize -> Tiny];{SetterBar[Dynamic[p], {Disk[] -> Disk, Rectangle[] -> Rectangle}], Dynamic[f[p]]}]

DynamicModule State  (3)

Use DynamicModule to save the displayed state across different Wolfram System sessions:

Wolfram Language code: DynamicModule[{x = 1}, Slider[Dynamic[x]]]
Wolfram Language code: InputForm[ToBoxes[%]]

Module only gives unique states in the current Wolfram System session:

Wolfram Language code: Module[{x = 1}, Slider[Dynamic[x]]]
Wolfram Language code: InputForm[ToBoxes[%]]

Use Initialization to evaluate expressions before displaying the contents:

Wolfram Language code: DynamicModule[{x = .5}, Slider[Dynamic[x]], Initialization :> (SelectionMove[EvaluationNotebook[], All, EvaluationCell];SetOptions[NotebookSelection[], CellFrame -> 1, CellFrameColor -> Hue[x]])]

Initialization is evaluated after the local variable assignments:

Wolfram Language code: DynamicModule[{a = 2}, Dynamic@a, Initialization :> (a = 1)]

Generalizations & Extensions  (1)

Define an arbitrary number of local variables by assigning down values to a variable:

Wolfram Language code: displayInputFields[numInputFields_] := DynamicModule[{values}, Do[values[i] = i, {i, numInputFields}]; InputField[Dynamic[values[#]]]& /@ Range[numInputFields]]
Wolfram Language code: displayInputFields[5]

Options  (16)

BaseStyle  (1)

Set the base style:

Wolfram Language code: DynamicModule[{x = "this is some text"}, Dynamic[x], BaseStyle -> {FontSize -> 8}]

Deinitialization  (1)

Specify expressions to be evaluated when output is no longer displayed:

Wolfram Language code: CreateDialog[DynamicModule[{c}, ColorSlider[Dynamic[c]], Initialization :> (c = Pink), Deinitialization :> (CreateDialog[Graphics[{c, Disk[]}]])]];

DynamicModuleValues  (1)

Function definitions of local symbols are automatically inserted into DynamicModuleValues:

Wolfram Language code: InputForm[DynamicModule[{c}, c[x_] := {x};c[1]]]

ExcludedContexts  (1)

By default, certain system-internal contexts are not saved in the initialization option:

Wolfram Language code: x := $TimeZone DynamicModule[{x}, x, SaveDefinitions -> True]//ToBoxes

Use ExcludedContexts{} to save definitions of all non-protected symbols:

Wolfram Language code: DynamicModule[{x}, x, ExcludedContexts -> {}, SaveDefinitions -> True]//ToBoxes

InheritScope  (1)

Create a dialog box with a DynamicModule that inherits variables from a parent DynamicModule:

Wolfram Language code: DynamicModule[{a = 1}, {Dynamic[a], Button["dialog", CreateDialog[DynamicModule[{}, Button["a++", a++], InheritScope -> True]]]}]

Initialization  (4)

By default, external definitions are lost between kernel sessions:

Wolfram Language code: f[x_] := {x}
Wolfram Language code: DynamicModule[{c}, {Slider[Dynamic[c]], Dynamic[f[c]]}]

Use Initialization to save evaluations necessary for the content:

Wolfram Language code: DynamicModule[{c}, {Slider[Dynamic[c]], Dynamic[g[c]]}, Initialization :> (g[x_] := {x})]

Local variables can also be initialized:

Wolfram Language code: DynamicModule[{c = 0.2, g}, {Slider[Dynamic[c]], Dynamic[g[c]]}, Initialization :> (g[x_] := {x})]

The initialization only runs if the output is displayed:

Wolfram Language code: DynamicModule[{}, 1, Initialization :> (x = 2)];DynamicModule[{}, 2, Initialization :> (y = 3)]

The first DynamicModule was suppressed by the semicolon, so it never ran its assignment:

Wolfram Language code: {x, y}

IncludedContexts  (1)

Limit recursive inclusion of symbol definitions to the contexts "c1`" and "c2`" only:

Wolfram Language code: c1`x := {c1`Private`bar , c2`baz} c1`Private`bar := 1 c2`baz := 3
Wolfram Language code: DynamicModule[{c1`x}, c1`x, IncludedContexts -> {"c1`", "c2`"}, SaveDefinitions -> True]//ToBoxes

SaveDefinitions  (2)

By default, external definitions are lost between kernel sessions:

Wolfram Language code: f[x_] := x
Wolfram Language code: DynamicModule[{u = 5}, Dynamic[f[u]]]

By setting SaveDefinitions to True, the external definitions are saved with the output:

Wolfram Language code: f[x_] := x
Wolfram Language code: DynamicModule[{u = 5}, Dynamic[f[u]], SaveDefinitions -> True]

SynchronousInitialization  (2)

By default, the initializations are evaluated before the output is displayed (synchronously):

Wolfram Language code: DynamicModule[{c = 0.2, g}, {Slider[Dynamic[c]], Dynamic[g[c]]}, Initialization :> (Pause[2];g[x_] := {x})]

Force the output to display while the initializations are evaluated asynchronously:

Wolfram Language code: DynamicModule[{c = 0.2}, {Slider[Dynamic[c]], Dynamic[g[c]]}, Initialization :> (Pause[2];g[x_] := {x}), SynchronousInitialization -> False]

UndoTrackedVariables  (1)

Create an interface that responds to the Undo menu command:

Wolfram Language code: DynamicModule[{a = 1}, {Button["increment", a++], Dynamic[a]}, UndoTrackedVariables :> {a}]

UnsavedVariables  (1)

Specify symbols whose state should not be saved:

Wolfram Language code: dm = DynamicModule[{x, y}, Column@{Slider[Dynamic[x]], Slider[Dynamic[y]], Dynamic[{x, y}]}, UnsavedVariables -> {y}];

Evaluate the following and move the two sliders, then click Close:

Wolfram Language code: nb = DialogInput[{dm, Button["Close", DialogReturn[NotebookGet[]]]}];

Evaluate the following and note that the second slider does not remember its previous state:

Wolfram Language code: nb = DialogInput[nb];

Applications  (3)

Construct a dynamic calculating interface:

Wolfram Language code: DynamicModule[{a = 0, b = 0}, Deploy[Style[Panel[Grid[Transpose[{{Style["input a number", Red], Style["input another number", Red], "here is their sum", "their difference", "their product"}, {InputField[Dynamic[a], Number], InputField[Dynamic[b], Number], InputField[Dynamic[a + b], Enabled -> False], InputField[Dynamic[a - b], Enabled -> False], InputField[Dynamic[a b], Enabled -> False]}}], Alignment -> Right], ImageMargins -> 10], DefaultOptions -> {InputField -> {ContinuousAction -> True, FieldSize -> {{5, 30}, {1, Infinity}}}}]]]

Interactive curve fit plot:

Wolfram Language code: DynamicModule[{pts = {{0, 0}, {1, 1}, {2, 0}, {3, 2}}}, LocatorPane[Dynamic[pts], Dynamic[Plot[InterpolatingPolynomial[pts, x], {x, 0, 3}, PlotRange -> 3]]]]

An angular slider with range :

Wolfram Language code: angularSlider[Dynamic[angle_]] := DynamicModule[{p = {1, 0}, angleCalc}, LocatorPane[Dynamic[p, (angleCalc@@Normalize /@ {#, p})&], Graphics[{Circle[], Arrowheads[0.15], Arrow[Dynamic[{{0, 0}, p}]]}, ImageSize -> Tiny], Appearance -> None], Initialization :> (angle = 0;angleCalc[newp_, oldp_] := (angle = angle + Abs[ArcCos[newp.oldp]]Sign[Cross[newp].(newp - oldp)];p = {Cos[angle], Sin[angle]}))]

Connect the slider to a dynamic variable:

Wolfram Language code: {angularSlider[Dynamic[θ]], Dynamic[θ]}

Demonstrate a sinusoidal relationship:

Wolfram Language code: DynamicModule[{θ = 0}, Grid[{{angularSlider[Dynamic[θ]], Plot[Sin[x], {x, -10, 10}, Epilog -> {PointSize[Medium], Dynamic@Point[{θ, Sin[θ]}]}]}, {ParametricPlot[{Cos[y], y}, {y, -10, 10}, AspectRatio -> 2, Epilog -> {PointSize[Medium], Dynamic@Point[{Cos[θ], θ}]}], Dynamic[θ]}}]]

Use PolarPlot to demonstrate a spiral curve:

Wolfram Language code: DynamicModule[{θ = 0}, Grid[{{angularSlider[Dynamic[θ]], Dynamic@PolarPlot[t, {t, -Pi, θ}, ImageSize -> Tiny]}}]]

Properties & Relations  (2)

DynamicModule and Module are fundamentally different although they seem similar:

Wolfram Language code: DynamicModule[{x}, {x, Slider[Dynamic[x]], Dynamic[x]}]
Wolfram Language code: %

In this case both sliders will move, and will not work without evaluation when reopened:

Wolfram Language code: Module[{x}, {x, Slider[Dynamic[x]], Dynamic[x]}]
Wolfram Language code: %

Manipulate relies on DynamicModule to create the output:

Wolfram Language code: Manipulate[x, {x, 0, 1}]
Wolfram Language code: DynamicModule[{x}, {Slider[Dynamic[x]], Dynamic[x]}]

Possible Issues  (2)

By default, definitions attached to "System`" symbols are not pulled in:

Wolfram Language code: x := Subscript[y, 1] Subscript[y, 1] := 17 Options[DynamicModule[{x}, x, SaveDefinitions -> True]//ToBoxes, Initialization]

Use ExcludedContexts{} to pull in definitions from all contexts:

Wolfram Language code: Options[DynamicModule[{x}, x, SaveDefinitions -> True, ExcludedContexts -> {}]//ToBoxes, Initialization]

Alternatively, attach definitions to your own symbols:

Wolfram Language code: Clear[Subscript] y/:Subscript[y, 1] = 17 Options[DynamicModule[{x}, x, SaveDefinitions -> True]//ToBoxes, Initialization]

Using an externally declared Module variable in a dynamic module produces a scope conflict:

Wolfram Language code: Module[{outer = 1}, DynamicModule[{inner = Hold[outer]}, Dynamic[ReleaseHold[inner]]]]

The boxes reference a leaked temporary Module symbol that has no value after the kernel quits:

Wolfram Language code: ToBoxes[%, StandardForm]

Use With to inject the fully resolved Module symbol so it is not referenced by the boxes:

Wolfram Language code: Module[{outer = 1}, With[{tmp = outer}, DynamicModule[{inner = Hold[tmp]}, Dynamic[ReleaseHold[tmp]]]]]

The boxes no longer reference the symbol:

Wolfram Language code: ToBoxes[%, StandardForm]

Neat Examples  (2)

Independent state sliders:

Wolfram Language code: Expand[(DynamicModule[{x}, Slider2D[Dynamic[x]]] + 1) ^ 3]

Click in the framed area to see bouncing balls:

Wolfram Language code: Framed@DynamicModule[{contents = {}}, EventHandler[Graphics[{PointSize[0.1], Point[Dynamic[contents = Map[If[#[[1, 2]] ≥ 0, {#[[1]] - #[[2]], #[[2]] + {0, 0.001}}, {{#[[1, 1]], 0}, {1, -0.8}#[[2]]}]&, contents];Map[First, contents]]]}, PlotRange -> {{0, 1}, {0, 1}}, ImageSize -> 80], "MouseDown" :> (AppendTo[contents, {MousePosition["Graphics"], {0, 0}}])]]

Use dynamic objects as input; click in the different frames to create additional balls:

Wolfram Language code: (% + 1) ^ 3//Expand

See Also

Dynamic  Module  Manipulate  LocalizeVariables  Interpretation

Function Repository: AsynchronousDynamicModule

Tech Notes

    ▪
  • Introduction to Dynamic
  • ▪
  • Advanced Dynamic Functionality
  • ▪
  • DynamicModule Scoping

Related Guides

    ▪
  • Dynamic Interactivity Language
  • ▪
  • Scoping Constructs
  • ▪
  • Low-Level Interface Control
  • ▪
  • Custom Interface Construction
  • ▪
  • Package Development
  • ▪
  • Click-Interactive Panels
  • ▪
  • Control Objects
  • ▪
  • Setting Up User Interactions

Related Workflows

    Related Workflows
    ▪
  • Put Autoupdating Dynamic Content in a Notebook
  • ▪
  • Use Locator Controls

History

Introduced in 2007 (6.0) | Updated in 2008 (7.0) ▪ 2014 (10.0) ▪ 2021 (12.3)

Wolfram Research (2007), DynamicModule, Wolfram Language function, https://reference.wolfram.com/language/ref/DynamicModule.html (updated 2021).

Text

Wolfram Research (2007), DynamicModule, Wolfram Language function, https://reference.wolfram.com/language/ref/DynamicModule.html (updated 2021).

CMS

Wolfram Language. 2007. "DynamicModule." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/DynamicModule.html.

APA

Wolfram Language. (2007). DynamicModule. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DynamicModule.html

BibTeX

@misc{reference.wolfram_2026_dynamicmodule, author="Wolfram Research", title="{DynamicModule}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/DynamicModule.html}", note=[Accessed: 01-September-2026]}

BibLaTeX

@online{reference.wolfram_2026_dynamicmodule, organization={Wolfram Research}, title={DynamicModule}, year={2021}, url={https://reference.wolfram.com/language/ref/DynamicModule.html}, note=[Accessed: 01-September-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • AI Access
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English