Controlling Fill and Stroke Opacity in SVGHMI Widgets

  • Cirill Sokolov
  • 20th November 2026
  • Reading time: ~6 min
ArticleWinCC Unified: fill and stroke opacity: article.image

Introduction

The opacity connection lets you control how transparent an SVG element's fill or stroke is, based on a WinCC Unified property. This is useful when you want to gradually fade elements in or out — for example, dimming an inactive zone on a process diagram, or making a pipe's outline semi-transparent to indicate a standby state.

The SVGHMI Converter generates hmi-bind:fill-opacity or hmi-bind:stroke-opacity attributes with a formula that converts the 0–100 integer range into the SVG-standard 0.0–1.0 range.

Fill Opacity and Stroke Opacity are premium connections: you can configure and preview them freely, downloading the converted widget needs purchased credits.

example preview of fill opacity

Configuration Fields

Upload your SVG to the SVGHMI Converter and add a Fill Opacity or Stroke Opacity connection. The form has four fields:

Element's ID

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

If the list is empty, open the SVG file in a vector editor (Inkscape, Illustrator), select the element, and assign it an id. You can target simple elements (rect, circle, path) or groups (g). If you select a group, all child elements will be affected, nested groups included.

Strict search (checkbox, checked by default):

  • Checked — matches one exact ID
  • Unchecked — partial matching: selects all elements whose ID starts with the entered text. For example, BgColor matches BgColor1, BgColor2, BgColor3, etc.

WinCC Property

The name of the property that will appear in WinCC Unified when you place the widget on a screen (Opacity / StrokeOpacity by default). Naming rules:

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

Examples: Opacity, FillTransparency, PipeOpacity

Default Value

Initial opacity percentage. Set to 100 by default (fully opaque). Accepts whole numbers from 0 (fully transparent) to 100 (fully opaque); anything above 100 is clamped at runtime.

The binding replaces the element's own fill-opacity / stroke-opacity. With the "Move 'opacity' to 'fill-opacity'" option (on by default), a plain opacity attribute is converted to fill-opacity and stroke-opacity first — so an element drawn at 50% opacity opens fully opaque unless you set the Default Value to 50.

Text Field's ID

Optional. Select a <text> or <textPath> element to display the current opacity value (the raw 0–100 number) at runtime.

Generated SVGHMI Code

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

Fill Opacity Binding

When you configure a fill opacity connection for an element with id="myRect" and property name Transparency, the converter produces:

<rect id="myRect"
      hmi-bind:fill-opacity="{{ Converter.Bounds(
          ParamProps.Transparency / 100, 0.0, 1.0) }}"
      .../>

The formula:

  • ParamProps.Transparency — integer value from WinCC (0–100)
  • / 100 — converts to SVG range (0.0–1.0)
  • Converter.Bounds(..., 0.0, 1.0) — clamps the result to prevent values outside the valid range

Stroke Opacity Binding

Stroke opacity works identically but targets the stroke-opacity attribute:

<rect id="myRect"
      hmi-bind:stroke-opacity="{{ Converter.Bounds(
          ParamProps.StrokeTransparency / 100, 0.0, 1.0) }}"
      .../>

Auto-Generated Parameter

Each opacity connection creates one hmi:paramDef in the widget metadata:

<hmi:paramDef name="Transparency" type="number" default="100"/>

If text binding is enabled (bindText: true — set automatically when you pick a text field), the converter also adds a text display:

<text id="opacityText">
  <hmi:text hmi-bind:value="{{ ParamProps.Transparency }}"/>
</text>

Example: Fill Opacity

Prerequisites for Opacity to Work

  • Fill Opacity requires the element to have a fill color or gradient assigned. If fill="none", there is nothing to make transparent — the binding is still added, but has no visible effect.
  • Stroke Opacity requires both a stroke color and a stroke-width to be set on the element. Without a visible stroke, opacity changes have no effect.
  • Stroke Opacity together with a Stroke color connection: connections are processed from top to bottom of the list, and Stroke Opacity skips elements whose stroke color has already been bound. Keep the Stroke Opacity connection above the Stroke connection for the same element (new connections are added at the top).

If you see a non-zero number in the conversion report (in square brackets) but the effect is not visible in WinCC, check these prerequisites. If a connection matched no element, its property is not added to the widget at all.

widget conversion reports

Example: Stroke Opacity

Connection Config Reference

The API accepts opacity connections with these fields:

FieldTypeDefaultDescription
typestring—"fill opacity" or "stroke-opacity"
propstringOpacity / StrokeOpacityProperty name for the generated hmi:paramDef
elemIdstring—Target SVG element ID
elemIdAllbooleantruetrue = exact match; false = prefix match
valuenumber100Default opacity percentage (0–100)
bindTextbooleanfalseDisplay value in a text element
textFieldstring—ID of a <text> element for value display

Additional Resources

FAQ

How does the converter map opacity from WinCC to SVG?

The property takes a whole number from 0 to 100. The converter divides it by 100 and clamps it with Converter.Bounds(value / 100, 0.0, 1.0), so 0 is fully transparent and 100 is fully opaque.

Why does fill opacity have no effect in WinCC Unified?

The element needs a fill color or gradient: with fill="none" there is nothing to make transparent. Stroke opacity needs both a stroke color and a stroke width.

Can I use Stroke Opacity together with a Stroke color connection?

Yes, but keep the Stroke Opacity connection above the Stroke connection for the same element. Connections are processed from top to bottom, and Stroke Opacity skips elements whose stroke color is already bound.

Why does an element drawn at 50% opacity open fully opaque?

The binding replaces the element's own opacity, and the Default Value is 100. Set the Default Value to 50 to keep the look from your drawing.

Related Posts :
WinCC Unified: tank level and progress bars article preview
WinCC Unified: tank level and progress bars

How to make a bar grow and shrink with a PLC value.

16th November 2026
WinCC Unified: rotate by angle article preview
WinCC Unified: rotate by angle

How to turn a gauge needle or valve handle by a PLC value.

18th 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