require(["esri/views/Theme"], (Theme) => { /* code goes here */ });
import Theme from "@arcgis/core/views/Theme.js";
esri/views/Theme
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:
- The lines and labels of DimensionAnalysis and DimensionLayer. Please use style instead.
- Theme colors don't affect the the profile lines of ElevationProfile. Please set colors on ElevationProfile.profiles instead.
- Theme colors don't affect the sight lines of LineOfSightLayer and LineOfSightAnalysis.
- Theme colors don't affect the visualization of ViewshedAnalysis.
// 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
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
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
-
The base color used to render temporary graphics in the View.
-
The base color used to render temporary labels in the View.
Method Overview
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
-
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();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey 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
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from Accessor -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType 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"); }
-
Inherited from Accessor
-
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");