Description
The spacing plugin extends the built in Tailwind spacing config and allows you to create preset responsive spacing groups. It will generate single class names following Tailwinds spacing classes for margin and padding which have responsive spacing instead of single fixed spacing.
Similiar to responsive typesets, at AREA 17 we like responsive spacing classes so that the spacing between components can be known and predictable. We don't use these for all components but we create rules to space full page width type blocks, or sections, or title bars from other content and then responsive spacing classes help us stay consistent between all these block types across all layouts and pages.
Setup
Output
These classes are linked to :root
variables that this plugin
also makes. For example, based on the reference config mentioned in this
guide, we get:
And then a series of margin and padding Tailwind classes to correspond to these. For example:
m-
, mx-
, my-
, mt-
,
mb-
, ml-
, mr-
, p-
,
px-
, py-
, pt-
, pb-
,
pl-
, pr-
classes will also be created, with appropriate negative classes.
From 4.0.5
, CSS logical property class names are also generated - ms-
, me-
, ps-
, pe-
, start-
and end-
, with appropriate negative classes.
Demo
The following div
has classes mt-outer-1
and
p-inner-1
and if you resize the window you will see the top
margin and inner padding will change in size as the browser window changes
size through the different breakpoints.
Content