# Want to set the default color of the reactangle tool

**URL:** <https://pdfjs.community/t/want-to-set-the-default-color-of-the-reactangle-tool/3054>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [January 4, 2024, 7:37am UTC](https://pdfjs.community/t/want-to-set-the-default-color-of-the-reactangle-tool/3054 "2024-01-04T07:37:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [January 4, 2024, 6:18pm UTC](https://pdfjs.community/t/want-to-set-the-default-color-of-the-reactangle-tool/3054/2 "2024-01-04T18:18:54Z")

</div>

Hello Shahid,

You can change the color of the rectangle tool programmatically like so:

```javascript
      documentViewer.addEventListener('documentLoaded', async () => {
        setIsDocumentLoadedSuccessfully(true);
        const rectangleTool = documentViewer.getTool('AnnotationCreateRectangle');
        // Set default styles
        rectangleTool.setStyles({
          FillColor: new Annotations.Color(255, 0, 0),
          StrokeColor: new Annotations.Color(0, 0, 0),
          StrokeWidth: 2,
        })
      });

```

Best Regards,  
Darian

---

_[View the full topic](https://pdfjs.community/t/want-to-set-the-default-color-of-the-reactangle-tool/3054)._
