# Viewer Flow(connection) styles changes

**URL:** <https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969>\
**Category:** Developers\
**Created:** [October 2, 2019, 1:33pm UTC](https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969 "2019-10-02T13:33:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sques](https://forum.bpmn.io/user_avatar/forum.bpmn.io/sques/32/1578_2.png) [@Sques](https://forum.bpmn.io/u/Sques)\
**Post date:** [October 2, 2019, 1:33pm UTC](https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969/1 "2019-10-02T13:33:43Z")

</div>

I’m using bmpn-js/lib/Viewer ( which is exported as default ).

```auto
import BpmnViewer from 'bpmn-js';

```

I just need to display the diagrams with process progress( receiving as a separate request as an array of ids ), so i’m using [bpmn-js-examples colors](https://github.com/bpmn-io/bpmn-js-examples/tree/master/colors) option 3, like this:  
js

```auto
const bpmnView = new BpmnViewer({
	height: '100%',
	container: '#BPMView'
});
bpmnView.importXML(xml, err => {
	// ...
	const canvas = bpmnView.get('canvas');
	const progressIdsArray = ['element1', 'element2', 'flow1']; // getting from separate request
	progressIdsArray.forEach(key => canvas.addMarker(key, 'highlight'))
	// ...
}

```

styles

```auto
.djs-element.highlight {

    .djs-visual > :nth-child(1) {
      stroke: $svg-highlight-stroke-color !important;
    }

    //&.djs-connection .djs-visual > path {
    // marker-end: url(#sequenceflow-active) !important;
    //}
  }

```

And it works fine except for painting the arrow  
 ![Screenshot_1](https://forum.bpmn.io/uploads/default/original/2X/c/ccff02f48210b1a4ade1663b3485cb8fe6deec0b.png)

I’m tried different solutions, like add custom marker to the defs tag

```auto
const svgSpecUrl = 'http://www.w3.org/2000/svg';
const setAttributes = (el, attrs) => Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]));

const redTriangleMarker = document.createElementNS(svgSpecUrl, 'marker');
const redTriangleMarkerAttrs = {
	id: "sequenceflow-active",
	viewBox: "0 0 20 20",
	refX: "11",
	refY: "10",
	markerWidth: "10",
	markerHeight: "10",
	orient: "auto"
};
setAttributes(redTriangleMarker, redTriangleMarkerAttrs);

const redTriangleMarkerPath = document.createElementNS(svgSpecUrl, 'marker');
const redTriangleMarkerPathAttrs = {
	d: "M 1 5 L 11 10 L 1 15 Z",
	style: "fill: red; stroke-width: 1px; stroke-linecap: round; stroke-dasharray: 10000, 1; stroke: red;"
};
setAttributes(redTriangleMarkerPath, redTriangleMarkerPathAttrs);

redTriangleMarker.appendChild(redTriangleMarkerPath);

const svgDefs = canvas.getContainer().getElementsByTagName('defs')[0];
if (!svgDefs) {
	// TODO create defs
}
svgDefs.appendChild(redTriangleMarker);

```

but nothing work

how can i paint the arrow in red?

---

<div class="post-metadata">

**Author:** ![Sques](https://forum.bpmn.io/user_avatar/forum.bpmn.io/sques/32/1578_2.png) [@Sques](https://forum.bpmn.io/u/Sques)\
**Post date:** [October 2, 2019, 3:11pm UTC](https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969/2 "2019-10-02T15:11:09Z")

</div>

Wow, i just found a mistake in my solution “add custom marker to the defs tag”. Need to change this

```auto
const redTriangleMarkerPath = document.createElementNS(svgSpecUrl, 'marker');

```

to this

```auto
const redTriangleMarkerPath = document.createElementNS(svgSpecUrl, 'path');

```

and uncomment the styles.

But is this a good solution or is there a better?

---

<div class="post-metadata">

**Author:** ![philippfromme](https://forum.bpmn.io/user_avatar/forum.bpmn.io/philippfromme/32/2803_2.png) [@philippfromme](https://forum.bpmn.io/u/philippfromme)\
**Post date:** [October 3, 2019, 9:58am UTC](https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969/3 "2019-10-03T09:58:52Z")

</div>

When using the modeler you can set an element’s color through

```javascript
modeling.setColor(myElement, { fill: 'red', stroke: 'green' });

```

The viewer doesn’t have this API but you can achieve the same using low-level APIs. Have a look at this example: [https://github.com/bpmn-io/bpmn-js-token-simulation/blob/master/lib/features/preserve-element-colors/PreserveElementColors.js#L52](https://github.com/bpmn-io/bpmn-js-token-simulation/blob/master/lib/features/preserve-element-colors/PreserveElementColors.js#L52)

---

<div class="post-metadata">

**Author:** ![Sques](https://forum.bpmn.io/user_avatar/forum.bpmn.io/sques/32/1578_2.png) [@Sques](https://forum.bpmn.io/u/Sques)\
**Post date:** [October 4, 2019, 9:12am UTC](https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969/4 "2019-10-04T09:12:07Z")

</div>

Thank you so much. I like your solution more

---

<div class="post-metadata">

**Author:** ![Tony\_Brown](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/t/9e8a1a/32.png) [@Tony\_Brown](https://forum.bpmn.io/u/Tony_Brown)\
**Post date:** [August 5, 2024, 12:36pm UTC](https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969/5 "2024-08-05T12:36:40Z")

</div>

How to solve it, is it convenient to take a look at the code?

---

<div class="post-metadata">

**Author:** ![Tony\_Brown](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/t/9e8a1a/32.png) [@Tony\_Brown](https://forum.bpmn.io/u/Tony_Brown)\
**Post date:** [August 5, 2024, 12:38pm UTC](https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969/6 "2024-08-05T12:38:29Z")

</div>

Do you have a more comprehensive implementation approach? I didn’t understand how to handle it based on the example

---

<div class="post-metadata">

**Author:** ![barmac](https://forum.bpmn.io/user_avatar/forum.bpmn.io/barmac/32/974_2.png) [@barmac](https://forum.bpmn.io/u/barmac)\
**Post date:** [July 9, 2025, 10:10am UTC](https://forum.bpmn.io/t/viewer-flow-connection-styles-changes/3969/7 "2025-07-09T10:10:22Z")

</div>

Closed on July 9, 2025, 10:10am UTC

Closing old topics.
