Can I access skinparam values as variables?

0 votes
asked Mar 24 in Question / help by boldandbusted (240 points)

Howdy. I'd like to do something like use `%darken($skinparamPackageBackgroundColor, "20")`. Even better would be able to reference `<<reference_name>>` grouped values as well. Is this possible in PlantUML today?

The purpose of this is so I can reduce the number of locations I have to statically set colors, and just use references to a base color to indicate various 'states' or 'modes' for components/packages (but any kind of object, really). Thanks in advance! :)

1 Answer

+1 vote
answered Mar 24 by The-Lu (45,820 points)

Hello B.,

With new style (v1.2022.2), you can use `--var`  variable on style.

Here is an attempt using style:

--packageBackground: #df00df;
package {
  BackGroundColor: var(--packageBackground);
component {
  'BackGroundColor: %darken(var(--packageBackground), 20);
  BackGroundColor: %darken("#df00df", 20);

package P
component C

But without result, then: 

@PlantUML team:

  • Could you allow style var (--var) on %building function parameter on style definition?

Thanks for your works,

commented Mar 25 by boldandbusted (240 points)
Thank you @The-Lu! Do you know if the new Style feature can completely supplant the use-case for 'skinparam'? Cheers!
commented Mar 25 by The-Lu (45,820 points)

Hello B.,

Do you know if the new Style feature can completely supplant the use-case for 'skinparam'? 

That is the goal... But with change management... as mentioned here:

We are confident that we will be able to support both versions (old skinparam and new style) at the same time. So we hope that there will be no breaking change when we will officially release it.

Supporting both versions at the same time will help users to take their time to migrate from skinparam to new style.

So if you find other issues, please post here :-)

See remarks on: