Theme

AMD: require(["esri/views/Theme"], (Theme) => { /* code goes here */ });
ESM: import Theme from "@arcgis/core/views/Theme.js";
Class: esri/views/Theme
Inheritance: Theme Accessor
Since: ArcGIS Maps SDK for JavaScript 4.28

This class is used by the View to define the base colors used by widgets and components to render temporary graphics and labels. It is important to note that the colors defined in this class are merely base colors. Widgets and components may create derived colors with varying opacity and contrast, and each widget and tool will display the theme colors in different ways.

The theme can be defined to complement an application's design or to contrast a map's content. For example, defining a purple accentColor will allow the user to clearly see measurement graphics on a red-orange colored basemap. Or defining a light textColor would display best against a dark background. Typically, theme colors are reactive and can be updated on-the-fly.

Currently, the following widgets and components honor this property. Note that the widgets available depends on if you are working in a 2D MapView or 3D SceneView: AreaMeasurement2D, dimensioning, AreaMeasurement3D, DirectLineMeasurement3D, DistanceMeasurement2D, draw tools, Editor, ElevationProfile, LineOfSight, Sketch, Slice, and snapping.

Known Limitations

Theme does not affect the following:

See also
Example
// Update the theme to use purple graphics
// and slightly transparent green text
view.theme = new Theme({
  accentColor: "purple",
  textColor: [125, 255, 13, 0.9]
});

Constructors

Theme

Constructor
new Theme(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

The base color used to render temporary graphics in the View.

Theme

The name of the class.

Accessor

The base color used to render temporary labels in the View.

Theme

Property Details

accentColor

Property
accentColor Colorautocast
Autocasts from Number[]|String|Object

The base color used to render temporary graphics in the View.

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

textColor

Property
textColor Colorautocast
Autocasts from Number[]|String|Object

The base color used to render temporary labels in the View.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.