Helpers are classes for very targeted “one-off” local overrides. Every helper declaration uses !important, and because they live in an mCSS cascade layer, that beats everything: all framework layers, your own unlayered CSS, even normal inline styles. Think of a helper as inline styling for a single element. That power is exactly why they should be used as little as possible, but they’re useful for things like:
Designer’s request to “make an exception”
Quick fix until refactor
Temporary test/design
Let’s say the request is: “This component just doesn’t look right in that context, can we just increase the top and bottom padding?” You would use the spacing helper this way:
<divclass="myComponent pt-lg3 pb-lg3">
<p>Content goes here.</p>
</div>
Using helpers is optional and mCSS will work just fine without them. None of the mCSS components rely on them. If you do use them in your project, it’s recommended to use PurgeCSS to keep your CSS size to a minimum. For Astro users, the astro-purgecss integration does everything for you out of the box once you install it.
Below is a list of all the available helpers. mCSS doesn’t include every single CSS property like utility classes frameworks do. It only includes the ones you actually need in those “one-off” situations. I’ve never needed more than that, but I’m open to add anything that would be useful. Just open an issue on Github with your use case and I’ll add it in.
You can combine these properties with any dimension token as well as 0:
CSS property
Class prefix
width
w
height
h
margin
m
margin-top
mt
margin-bottom
mb
margin-left
ml
margin-right
mr
margin-inline-start
mis
margin-inline-end
mie
padding
p
padding-top
pt
padding-bottom
pb
padding-left
pl
padding-right
pr
padding-inline-start
pis
padding-inline-end
pie
Both directional sets exist on purpose. Use the logical helpers (mis, mie, pis, pie) when the spacing follows the reading direction: an icon gap, a list indent, anything that should flip in a right-to-left layout. Use the physical helpers (ml, mr, pl, pr) when the offset is a purely visual choice that should stay on the same side no matter the script direction. In a left-to-right layout they resolve identically.
Same split as the spacing helpers: .text-start and .text-end follow the reading direction (they flip in a right-to-left layout), .text-left and .text-right always mean the visual side.