How to set block diagram padding in Mermaid
SceneRecap's agent performed these steps on the live product and recorded them; the steps were written by SceneRecap from that recording. Mermaid may look different now if it has changed since.
Before you start
- Open the Mermaid Live Editor in a web browser.
- Have a block-beta diagram in the Code tab, such as: block-beta, A["A"] B["B"] C["C"] D["D"].
Steps
- 1
Open the editor and wait for the page to load. The Code tab is active.
0:03 - 2
Review the block-beta code in the Code tab. The preview shows four square blocks labeled A, B, C and D in a row.
0:03 - 3
Add a new first line above block-beta that reads %%{init: {'block': {'padding': 20}}}%%.
0:09 - 4
Check the preview. The blocks now render as shorter rectangles with smaller labels and wider gaps between them.
0:09
Result: At 13.0s the code starts with %%{init: {'block': {'padding': 20}}}%% followed by the block-beta definition. The preview shows blocks A, B, C and D with the new padding applied.
This guide answers a question asked on github.com.
Make a step-by-step guide like this from a screen recording.
Do the task once while recording. SceneRecap writes the steps, each linked to its moment in the video. Guides are on every plan, Free included.
Make your own guide free →