1. Guides
  2. Sizes in Sanity UI

Sizes in Sanity UI

Why does Sanity UI use a number-based spacing scale?  

Some UI libraries use spacing keys like nonexssml , xl, etc., while Sanity UI uses numeric spacing keys.
For example – this is how you define the spacing/size of a button in Chakra UI:
<Button colorScheme='teal' size='sm'>
  Button
</Button>
While in Sanity UI you do:
<Button padding={2} tone="primary" text="Button" />
These are some advantages of number-based spacing scales:
  • Simpler to learn.
  • Shorter keys, faster to use.
  • Enables arithmetic like padding={paddingProp - 1}
  • Enables negative spacing like margin={-4}

What do the numbers mean?  

The numbers are part of a spacing scale.
The spacing scale in Sanity UI is a sequence of 10 numbers – 0 to 9. Each number represent a spacing value:
  • 0 = 0px
  • 1 = 4px
  • 2 = 8px
  • 3 = 12px
  • 4 = 20px
  • 5 = 32px
  • 6 = 52px
  • 7 = 84px
  • 8 = 136px
  • 9 = 220px
Using a fibonacci scale gives us an effective scale for combining different paddings and get balanced and aligned compositions.
The Fibonacci scale
Which means:
<Card padding={0}> // no padding
<Card padding={1}> // 4px padding
<Card padding={4}> // 20px padding
<Card padding={6}> // 52px padding
and so on.

Other projects using number-based spacing scales  

Made withby folks at