Search code examples
plantuml

Plantuml no padding in rectangle


Is there any way of removing the padding from a rectangle in plantuml?

I have tried the following:

rectangle "rect1" as A1 #line:transparent;back:transparent

rectangle "rect2" as A2 #line:transparent;back:transparent


A1 -- A2

in my final diagram I will replace the text with an image, so maybe there is a better for images in the first place?

I've tried

rectangle "rect1" as A1 #line:transparent;back:transparent;padding:0

and tried skinParams too, but couldn't get it to work in any way


Solution

  • Padding settings are a work in progress as far as I can tell. See the discussion in the forum here. There's official documentation that says padding can be styled, but it doesn't seem to work properly for class diagrams. This is a question for the forum of PlantUML.

    That said, here's a result you might find useful:

    @startuml images
    <style>
    classdiagram {
        linecolor red
        class {
            padding 0  <-- doesn't work
            linecolor green
            BackgroundColor yellow
        }
    }
    </style>
    
    skinparam style strictuml
    skinparam padding 0
    hide empty members
    class "<img:http://plantuml.com/logo3.png{scale=0.5}>" as c1 
    class "<img:http://plantuml.com/logo3.png{scale=0.5}>" as c2
    c1 - c2
    @enduml
    

    I purposefully left the background color and line color so you can see the padding. Just set them to transparent for best results.

    Perhaps you can try using other elements in PlantUML (rectangle, component, package, etc.) to see if a setting of padding 0 is respected.

    Sample image