@startgantt
[Activity1] lasts 5 days
[Activity2] lasts 5 days
[Activity1] is colored in White/Red
[Activity2] is colored in Silver/SeaGreen
[Activity1] -> [Activity2]
@endgantt
PlantUML allows dynamic font color selection using the #? syntax. The system automatically chooses between two colors based on the current background color to ensure optimal contrast and readability.
How It Works:
The #? prefix defines a conditional color choice.
Two colors follow, separated by a colon.
The engine selects one based on the background:
If the background is light, it uses the first color.
If the background is dark, it uses the second color to maintain contrast.
Thus, the #?black:white syntax ensures that text remains legible across different background colors.
@startuml
<style>
document {
BackGroundColor darkblue
}
root {
FontColor #?black:white
LineColor white
}
</style>
alice -> bob : hello
@enduml
In this example, since the background is dark blue, the font color automatically switches to white for better contrast in the message "hello", while keeping black for the participant labels.
A user has recently created an image to display all names colors used by PlantUML. (We thank him by the way!)
So a new feature has been added to print all those colors using a special diagram description:
@startuml
colors
@enduml
It is also possible to print a palette of colors close to some other color (using its name or HEX value).
@startuml
colors chocolate
@enduml
Archimate colors
Archimate uses color names that reflect the purpose of a node: