#Spacing

import { spacingSystem } from '@poodle/system'

The spacing system helps us to create a spacing scaling. Any props in the spacing system can use spacing scaling.

With theme.spacing.scale we can set it with a number, string (rem, em...). The prop send in can be scaling multiply.

For example theme.spacing.scale = 4 then mt = "4" will be equal to marginTop = "16".

The system chooses the value "scale-number" because it's easy to spot where are we using scaling for spacing when we refactor the code.

We can also use theme.spacing.sets to predefine a list spacing we want.

const theme = {
spacing: {
scale: 4,
sets: {
custom: "1rem",
"custom-2": (props) => {
return props.other + 10;
},
},
},
};
const listSystem = compose(colorsSystem, spacingSystem);
export const system = createSystem(listSystem);
const styles = system({
theme,
other: 5,
mt: "scale-4",
pt: "custom",
pl: "custom-2",
})
// Styles result
// { other: 5 },
// { marginTop: "16" },
// { paddingTop: "1rem" },
// { paddingLeft: 15 },
PropTypeDescription
mResponsiveProp<CSS.Property.Margin \| number>The CSS margin property
marginResponsiveProp<CSS.Property.Margin \| number>The CSS margin property
marginBottomResponsiveProp<CSS.Property.MarginBottom \| number>The CSS margin property
marginLeftResponsiveProp<CSS.Property.MarginLeft \| number>The CSS margin-left property
marginRightResponsiveProp<CSS.Property.MarginRight \| number>The CSS margin-right property
marginTopResponsiveProp<CSS.Property.MarginTop \| number>The CSS margin-top property
marginXResponsiveProp<CSS.Property.Margin \| number>The CSS margin-top and margin-bottom property
marginYResponsiveProp<CSS.Property.Margin \| number>The CSS margin-top and marin-bottom property
mbResponsiveProp<CSS.Property.MarginBottom \| number>The CSS margin-bottom property
mlResponsiveProp<CSS.Property.MarginLeft \| number>The CSS margin-left property
mrResponsiveProp<CSS.Property.MarginRight \| number>The CSS margin-right property
mtResponsiveProp<CSS.Property.MarginTop \| number>The CSS margin-top property
mxResponsiveProp<CSS.Property.Margin \| number>The CSS margin-top and margin-bottom property
myResponsiveProp<CSS.Property.Margin \| number>The CSS margin-top and marin-bottom property
pResponsiveProp<CSS.Property.Padding \| number>The CSS padding property
paddingResponsiveProp<CSS.Property.Padding \| number>The CSS padding property
paddingBottomResponsiveProp<CSS.Property.PaddingBottom \| number>The CSS padding-bottom property
paddingLeftResponsiveProp<CSS.Property.PaddingLeft \| number>The CSS padding-left property
paddingRightResponsiveProp<CSS.Property.PaddingRight \| number>The CSS padding-right property
paddingTopResponsiveProp<CSS.Property.PaddingTop \| number>The CSS padding-top property
paddingXResponsiveProp<CSS.Property.Padding \| number>The CSS padding-top and padding-bottom property
paddingYResponsiveProp<CSS.Property.Padding \| number>The CSS padding-left and padding-right property
pbResponsiveProp<CSS.Property.PaddingBottom \| number>The CSS padding-bottom property
plResponsiveProp<CSS.Property.PaddingLeft \| number>The CSS padding-left property
prResponsiveProp<CSS.Property.PaddingRight \| number>The CSS padding-right property
ptResponsiveProp<CSS.Property.PaddingTop \| number>The CSS padding-top property
pxResponsiveProp<CSS.Property.Padding \| number>The CSS padding-top and padding-bottom property
pyResponsiveProp<CSS.Property.Padding \| number>The CSS padding-left and padding-right property