Dynamic Stroke Width in SVGHMI Widgets

  • Cirill Sokolov
  • 1st December 2026
  • Reading time: ~6 min
ArticleWinCC Unified: dynamic stroke width: article.image

Introduction

The stroke width connection lets you change line thickness of SVG elements at runtime through a WinCC Unified property. For example, you might want pipe outlines to grow thicker as pressure increases, or make a border more prominent when an alarm is active.

The SVGHMI Converter also supports a FixedOnScale mode — a common need when you resize widgets but want the lines to stay the same visual thickness.

SVGHMI Stroke Width Configuration

Configuration Fields

Upload your SVG to the SVGHMI Converter and add a Stroke Width connection. The form has five fields:

Fixed on Scaling

The Fixed on scaling checkbox controls how stroke width behaves when the widget is resized in WinCC:

  • Checked (default) — the widget gets a FixedOnScale property. While it is true at runtime, the stroke width is recalculated from the widget's actual width versus the viewBox width, so lines keep the same on-screen thickness regardless of widget size.
  • Unchecked — the value is used as-is, in the SVG's own (viewBox) units. Lines become thicker or thinner as the widget scales.

Element's ID

Select the target element from the dropdown or type its ID manually.

If the list is empty, open the SVG in a vector editor and assign an id to the element. You can target rect, circle, path, or groups (g). Selecting a group applies stroke width control to all children, including nested groups.

Strict search (checkbox):

  • Checked — matches one exact ID
  • Unchecked — partial matching: selects all elements whose ID starts with the entered text

WinCC Property

The property name that appears in WinCC Unified when the widget is placed on a screen. The converter suggests StrokeWidth. Rules:

  • Must not be empty
  • Letters and digits only — no spaces, underscores or special characters
  • Must start with a letter

Examples: BorderWidth, LineThickness, PipeStroke

Default Value

Initial stroke width, 1 by default. The form accepts numbers from 0 to 100.

Text Field's ID

Optional. Select a <text> or <textPath> element to display the current stroke width value at runtime. The converter replaces the element's content with <hmi:text hmi-bind:value="{{ ParamProps.BorderWidth }}"/>.

Generated SVGHMI Code

Long expressions below are wrapped for readability; the converter writes each binding on one line.

Simple Binding (no fixed scaling)

When scaleFixed is disabled, the converter produces a direct binding:

<rect id="myRect"
      hmi-bind:stroke-width="{{ParamProps.BorderWidth}}"
      .../>

FixedOnScale Binding

When scaleFixed is enabled (default), the converter generates a conditional binding:

<rect id="myRect"
      hmi-bind:stroke-width="{{ ParamProps.FixedOnScale
          ? ParamProps.BorderWidth * 210 / HmiProps.Width
          : ParamProps.BorderWidth }}"
      .../>

Where 210 is the viewBox width of the converted SVG and HmiProps.Width is the widget's actual width on the WinCC screen. The formula:

  • ParamProps.FixedOnScale = true → value * viewBoxWidth / actualWidgetWidth. A widget stretched to 420px gets half the stroke width in SVG units — after the 2× stretch that is exactly BorderWidth pixels on screen, the same visual thickness as before.
  • ParamProps.FixedOnScale = false → the value is used directly, so the line scales together with the widget.

Only the widget's width enters the formula. Converted widgets use preserveAspectRatio="none", so if you stretch a widget mostly in height, horizontal lines will still get thicker — resize proportionally for the best result.

In both cases the static stroke-width attribute is removed from the element — the binding takes over.

Auto-Generated Parameters

Each stroke width connection creates a hmi:paramDef entry (the default comes from the Default Value field):

<hmi:paramDef name="BorderWidth" type="number" default="1"/>

When scaleFixed: true, an additional parameter is generated:

<hmi:paramDef name="FixedOnScale" type="boolean" default="true"/>

FixedOnScale is a single widget-wide switch: if you add several stroke width connections with fixed scaling, they all share it.

WinCC Unified SVG scaling behavior

Troubleshooting

Stroke width not changing in WinCC:

  • Check the element's stroke. If the element has no stroke attribute at all, the converter adds stroke="#000000" so the width is visible. But stroke="none" is kept as is — the width changes, yet there is nothing to see. Set a stroke color in your editor (or add a Stroke color connection).
  • Check that the property name matches exactly in the WinCC properties panel.

Unexpected black outlines after conversion:

  • When you target a group, every child without its own stroke gets stroke="#000000". If the group contains filled shapes that should stay without an outline, target the outlined elements individually (or by a shared ID prefix with Strict search off) instead of the whole group.

Lines too thick or too thin after resizing:

  • Enable the FixedOnScale option. Without it, stroke width scales with the widget dimensions and may appear disproportionate.

Connection Config Reference

FieldTypeDefaultDescription
typestring—"stroke-width"
propstringStrokeWidthProperty name for the generated hmi:paramDef
elemIdstring—Target SVG element ID
elemIdAllbooleantruetrue = exact match; false = prefix match
valuenumber1Default stroke width
scaleFixedbooleantrueAdd FixedOnScale runtime toggle for viewBox-relative scaling
bindTextbooleanfalseDisplay value in a text element
textFieldstring—ID of a <text> element for value display

Additional Resources

FAQ

What is FixedOnScale in SVGHMI?

A boolean widget property the converter adds when Fixed on scaling is checked. While it is true, the stroke width is recalculated as value × viewBox width / actual widget width, so lines keep the same thickness on screen at any widget size.

Why do lines look thicker after I resize the widget?

Without FixedOnScale the stroke width is in SVG units and scales with the widget. Only the widget width enters the FixedOnScale formula, so stretching a widget mostly in height still makes horizontal lines thicker: resize proportionally.

Why does the stroke width not change at runtime?

Check the stroke color. An element with stroke="none" keeps it, so the width changes but nothing is visible. Set a stroke color in your editor or add a Stroke color connection.

Why did black outlines appear after conversion?

Elements without their own stroke get stroke="#000000" so the width is visible. If you target a group, its filled shapes get outlines too: target the outlined elements by ID or ID prefix instead.

Related Posts :
WinCC: svg to svghmi widget converter article preview
WinCC: svg to svghmi widget converter

How to automatically convert a vector svg image into a dynamic widget?

4th August, 2023
WinCC Unified: fill and stroke opacity article preview
WinCC Unified: fill and stroke opacity

How to fade parts of an SVG widget by a PLC value.

20th November 2026

Have a Question? Get in touch!

Start working with SVGHMI.pro that can provide you with effective tools to create SCADA HMIs and reduce maintenance costs.

Can I purchase as a business?

Yes! Our payment system supports business purchases with Wire Transfer, Purchase Order options, VAT ID registration, and proper invoicing for your accounting department. All transactions are securely processed by PayProGlobal, our trusted e-commerce partner.

Contact us