Theme customization

Spacing

Customizing the default spacing and sizing scale for your project.

Componentry's default spacing scale mirrors the spacing scale used by Tailwind. Out of the box this provides a wide set of values for creating cohesive layouts.

auto

auto

0

(0px)

px

(1px)

0.5

(0rem/0px)

1

(0.25rem/4px)

1.5

(0.25rem/4px)

2

(0.5rem/8px)

2.5

(0.5rem/8px)

3

(0.75rem/12px)

4

(1rem/16px)

5

(1.25rem/20px)

6

(1.5rem/24px)

8

(2rem/32px)

10

(2.5rem/40px)

12

(3rem/48px)

14

(3.5rem/56px)

16

(4rem/64px)

20

(5rem/80px)

24

(6rem/96px)

32

(8rem/128px)

48

(12rem/192px)

64

(16rem/256px)

Arbitrary values

Spacing props also accept arbitrary values. Any value not found in your theme.spacing defintion will be passed through as a style.

Spacing ratio

When using arbitrary values for spacing it's common to use a ratio to help simplify consistent spacing. Componentry provides a theme.spacingRatio definition to support this. It's expected to accept any number and return a valid CSS string value.

// theme definition module.exports.theme = { // Convert any arbitrary spacing value to an 8px grid spacingRatio: (input) => (input * 8) + 'px' } // 7 isn't part of the spacing scale, will be converted to 56px <Block pt={7}> grid support </Block>