> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/annotation/customizing-default-annotation-styles.md).

# Customizing default annotation styles

Discover how to customize default annotation styles effortlessly. Learn to tweak stroke color, thickness, fill color, text attributes, and more for a personalized touch. Elevate your annotations with

An annotation's default style is the style it is created with when created through its associated tool. For example, a freetext annotation create tool may set the stroke color, stroke thickness, fill color, text color, font size and/or opacity of the annotation shortly after creation, which becomes their 'default' or initial style.

## Changing the default annotation style

To change the default style, you can use the [setStyles](https://sdk.apryse.com/api/web/Core.Tools.Tool.html#setStyles__anchor) API on the tool objects.

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({ ... }, viewerElement)
  .then(instance => {
    const { documentViewer, Annotations } = instance.Core;

    documentViewer.getTool('AnnotationCreateTextHighlight').setStyles({
      StrokeColor: new Annotations.Color(0, 221, 255)
    });

    documentViewer.getTool('AnnotationCreateFreeText').setStyles({
      StrokeThickness: 5,
      StrokeColor: new Annotations.Color(0, 0, 255),
      TextColor: new Annotations.Color(0, 0, 0),
      FontSize: '20pt'
    });
  });
```

{% endcode %}

[WebViewerInstance](https://sdk.apryse.com/api/web/WebViewerInstance.html) [Core](https://sdk.apryse.com/api/web/Core.html) [DocumentViewer.getTool](https://sdk.apryse.com/api/web/Core.DocumentViewer.html#getTool__anchor) [Annotations](https://sdk.apryse.com/api/web/Core.Annotations.html)
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({ ... }, viewerElement)
  .then(instance => {
    const { docViewer, Annotations } = instance;

    docViewer.getTool('AnnotationCreateTextHighlight').setStyles(currentStyle => ({
      StrokeColor: new Annotations.Color(0, 221, 255)
    }));

    docViewer.getTool('AnnotationCreateFreeText').setStyles(currentStyle => ({
      StrokeThickness: 5,
      StrokeColor: new Annotations.Color(0, 0, 255),
      TextColor: new Annotations.Color(0, 0, 0),
      FontSize: '20pt'
    }));
  });
```

{% endcode %}

[WebViewerInstance](https://sdk.apryse.com/api/web/WebViewerInstance.html) [DocumentViewer.getTool](https://sdk.apryse.com/api/web/Core.DocumentViewer.html#getTool__anchor) [Annotations](https://sdk.apryse.com/api/web/Core.Annotations.html)
{% endtab %}
{% endtabs %}

## Using the `defaults` object

On the annotation create tools, you will find a `defaults` object that contains the values used to initialize the annotation style properties. If you need to read the initial values, you can use this object.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
WebViewer({ ... }, viewerElement)
  .then(instance => {
    const { documentViewer, Annotations } = instance.Core;

    const highlightCreateTool = documentViewer.getTool('AnnotationCreateTextHighlight');

    highlightCreateTool.defaults.StrokeColor = new Annotations.Color(0, 221, 255);

    console.log(highlightCreateTool.defaults.StrokeColor);
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
WebViewer({ ... }, viewerElement)
  .then(instance => {
    const { docViewer, Annotations } = instance;

    const highlightCreateTool = docViewer.getTool('AnnotationCreateTextHighlight');

    highlightCreateTool.defaults.StrokeColor = new Annotations.Color(0, 221, 255);

    console.log(highlightCreateTool.defaults.StrokeColor);
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Next steps

If you want to check out which properties are available on the annotations themselves, check out the [annotation type guides](/web/annotation/annotation-types/rectangleannotation.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/web/annotation/customizing-default-annotation-styles.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
