Padding and Margin in Card or Rectangles not working

+1 vote
asked Dec 3, 2024 in Question / help by VS (120 points)

Hello, I am trying to add padding and margin to a card and rectangle. But it is not showing up. I don't know if this is a bug or just not implemented yet. 

Link to an example:https://www.plantuml.com/plantuml/uml/SoWkIImgAStDuR8fBgdCIRNZIauiIb6evWf8J4d9p4jNC3JWyaqiIi_CKp3bgkKgIaqkISnBpqb5KG5J0c825TdeGus2c0KY787g5HGKuDh1B4TC8IUkMeGc9oukY5vTNJke04WDCjyXDIy5w7W0

Code:

@startuml
<style>
card {
Padding 10
Margin 5
}
rectangle {
Padding 100
Margin 100
}
</style>

card cardA {
   rectangle rectA
   rectangle rectB
}
card cardB
cardA --> cardB
rectA --> cardB
@enduml

You can change the values for padding and margin, and nothing happens on the diagrams.
It works for root, but not for card/rectangle or even stereotypes.

1 Answer

+1 vote
answered Mar 5 by anonymous

I ran an experiment.  For many of the PlantUml elements I displayed them with padding and margin set to 5.

image

@startuml
<style>
.stereo {
  BackgroundColor palegreen
  padding 5
  margin 5
}
</style>
hide stereotype

actor actor << stereo >>
actor/ "actor/" << stereo >>
agent agent << stereo >>
artifact artifact << stereo >>
boundary boundary << stereo >>
card card << stereo >>
circle circle << stereo >>
cloud cloud << stereo >>
collections collections << stereo >>
component component << stereo >>
control control << stereo >>
database database << stereo >>
entity entity << stereo >>
file file << stereo >>
folder folder << stereo >>
frame frame << stereo >>
hexagon hexagon << stereo >>
interface interface << stereo >>
label label << stereo >>
node node << stereo >>
package package << stereo >>
person person << stereo >>
queue queue << stereo >>
rectangle rectangle << stereo >>
stack stack << stereo >>
storage storage << stereo >>
usecase usecase << stereo >>
usecase/ "usecase/" << stereo >>
@enduml

I then changed 5 to 50

image

with the following code

@startuml
<style>
.stereo {
  BackgroundColor palegreen
  padding 50
  margin 50
}
</style>
hide stereotype

actor actor << stereo >>
actor/ "actor/" << stereo >>
agent agent << stereo >>
artifact artifact << stereo >>
boundary boundary << stereo >>
card card << stereo >>
circle circle << stereo >>
cloud cloud << stereo >>
collections collections << stereo >>
component component << stereo >>
control control << stereo >>
database database << stereo >>
entity entity << stereo >>
file file << stereo >>
folder folder << stereo >>
frame frame << stereo >>
hexagon hexagon << stereo >>
interface interface << stereo >>
label label << stereo >>
node node << stereo >>
package package << stereo >>
person person << stereo >>
queue queue << stereo >>
rectangle rectangle << stereo >>
stack stack << stereo >>
storage storage << stereo >>
usecase usecase << stereo >>
usecase/ "usecase/" << stereo >>
@enduml

I would say that most elements do not support margin and padding <style> based styling.

Dick Maley

...