Obsidian uses a 4-pixel grid to structure UI elements. By using multiples of 4 for padding and margin, the grid provides convenient ratios for layouts and allows the interface to scale up and down across high and low DPI screens.

To align with the 4-pixel grid, all elements should use the predefined --size CSS variables for spacing and dimensions properties.

Each size variable contains two numbers which represent the base and the multiple.

  • --size-4-1 represents 4px (4x1)
  • --size-4-2 represents 8px (4x2)
  • --size-4-4 represents 16px (4x4)

In addition to the 4-pixel grid, Obsidan also provides a set of variables that uses a 2-pixel grid. Use these sparingly and only when you need more fine-grained spacing.

VariableDefault value
--size-2-12px
--size-2-24px
--size-2-36px
--size-4-14px
--size-4-28px
--size-4-312px
--size-4-416px
--size-4-520px
--size-4-624px
--size-4-832px
--size-4-936px
--size-4-1248px
--size-4-1664px
--size-4-1872px