How to style groups (alt, loop etc.) using skin params?

0 votes
asked Apr 11, 2022 in Question / help by anonymous
There are some answers about how to add background color, e.g.: https://forum.plantuml.net/4750

But I want to style all the elements: border color, font color of title, background of title, font color of caption, background of caption.

Is this possible using skin params?

1 Answer

0 votes
answered Apr 11, 2022 by The-Lu (64,340 points)

Hello A.,

After:

You can see:

Then here is an example, using style, as:

@startuml
hide footbox
<style>
sequenceDiagram {
  participant {
    BackGroundColor white
    LineThickness 1
  }
  group {
    FontStyle italic
    LineThickness 1
    LineColor blue
    LineStyle 3
    BackGroundColor LightSeaGreen
  }
  groupHeader {
    FontStyle plain
    FontColor red
    BackGroundColor palegreen
    LineColor maroon
    LineStyle 3
  }
}
</style>

participant A
participant B

group group label
A-->B : msg
activate A
activate B
A<--B : return
deactivate A
deactivate B
end group

alt alt label
A -> B : msg1
else 
A -> B : msg2
end alt

loop loop label
A -> B : msg3
end loop

<style>
sequenceDiagram {
  group {
    FontStyle bold
    LineThickness 3
    LineColor blue
    LineStyle 10
    BackGroundColor pink
  }
  groupHeader {
    FontStyle bold
    FontColor red
    BackGroundColor palegreen
    LineColor red
    LineStyle 10
  }
}
</style>
loop loop label
A -> B : msg4
end loop
@enduml

Enjoy,
Regards.

commented Apr 12, 2022 by anonymous
Almost there, thanks for the answer!

Is there any way to adjust the background color, padding, margin or alignment of the loop / alt label?

Part of the label is not visible because of the underlying lifeline.
commented Apr 13, 2022 by The-Lu (64,340 points)

Hello A.,

Seems to be not yet implemented...
But a possible workaround, for alt/loop label, will be to use creole `back` colour, for example with `<back:LightSeaGreen>` as:

See also similar question here:

Then you can also use `\r` and `\l` to manage alignment... 

If that can help,
Regards.

...