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
(0px)
(1px)
(0rem/0px)
(0.25rem/4px)
(0.25rem/4px)
(0.5rem/8px)
(0.5rem/8px)
(0.75rem/12px)
(1rem/16px)
(1.25rem/20px)
(1.5rem/24px)
(2rem/32px)
(2.5rem/40px)
(3rem/48px)
(3.5rem/56px)
(4rem/64px)
(5rem/80px)
(6rem/96px)
(8rem/128px)
(12rem/192px)
(16rem/256px)
Spacing props also accept arbitrary values. Any value not found in your theme.spacing
defintion will be passed through as a style.
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>