current theme: placeholder

Docs :: Helpers

Helpers are classes with high specificity for very targeted “one-off” local overrides. 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:

<div class="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.

Spacing

File nameSource
help.spacing.cssGithub

width, height, margin, and padding

You can combine these properties with any dimension token as well as 0:

CSS propertyClass prefix
widthw
heighth
marginm
margin-topmt
margin-bottommb
margin-leftml
margin-rightmr
paddingp
padding-toppt
padding-bottompb
padding-leftpl
padding-rightpr

Examples

ClassValue
w-lg1width: var(--lg1)
ml-0margin-left: 0
mb-sm1margin-bottom: var(--sm1)
<div class="component mb-lg3">
  A component with an extra bottom margin of 48px.
</div>

<div class="component p-md1">A component with an extra padding of 28px.</div>

Colors

File nameSource
help.colors.cssGithub

color, background-color, and border-color

You can combine this properties with any color token:

CSS propertyClass prefix
colorc
background-colorbgc
border-colorbdc

Examples

ClassValue
bgc-base-200background-color: var(--base-200)
bdc-yes-500border-color: var(--yes-500)
color-primary-500color: var(--primary-500)

A block with with custom colors.

<div class="c-base-0 bgc-primary-600">
  <p>A block with with custom colors.</p>
</div>

Layout

File nameSource
help.layout.cssGithub

overflow

CSS propertyCSS valueClassShort class
overflowauto.overflow-auto.of-auto
overflowhidden.overflow-hidden.of-hidden
overflowclip.overflow-clip.of-clip
overflowvisible.overflow-visible.of-visible
overflowscroll.overflow-scroll.of-scroll
overflow-xauto.overflow-x-auto.of-x-auto
overflow-yauto.overflow-y-auto.of-y-auto
overflow-xhidden.overflow-x-hidden.of-x-hidden
overflow-yhidden.overflow-y-hidden.of-y-hidden
overflow-xclip.overflow-x-clip.of-x-clip
overflow-yclip.overflow-y-clip.of-y-clip
overflow-xvisible.overflow-x-visible.of-x-visible
overflow-yvisible.overflow-y-visible.of-y-visible
overflow-xscroll.overflow-x-scroll.of-x-scroll
overflow-yscroll.overflow-y-scroll.of-y-scroll

position

Helper classes for the position property.

CSS valueClassShort class
static.position-static.static
fixed.position-fixed.fixed
absolute.position-absolute.absolute
relative.position-relative.relative
sticky.position-sticky.sticky

visibility

Helper classes for the visibility property.

CSS valueClassShort class
visible.visibility-visible.visible
hidden.visibility-hidden.hidden
collapse.visibility-collapse.collapse
collapse.visibility-collapse.collapse

z-index

Helper classes for the z-index property. See also the z-index token docs.

Custom PropertyCSS ValueClass
--z-bottom-1000000000.z-bottom
--z-00.z-0
--z-110.z-1
--z-220.z-2
--z-330.z-3
--z-440.z-4
--z-550.z-5
--z-top1000000000.z-top

Aspect ratios

File nameSource
help.ratios.cssGithub
Custom PropertyCSS ValueClass
--ar-square1.ar-square
--ar-landscape4/3.ar-landscape
--ar-portrait3/4.ar-portrait
--ar-widescreen16/9.ar-widescreen
--ar-golden1.618/1.ar-golden

Typography

File nameSource
help.typography.cssGithub

font-family

See the font stack tokens for details.

Custom PropertyClassShort class
--text.font-text.text
--display.font-display.display
--mono.font-mono.mono

font-style

CSS valueClass
italic.font-italic
normal.font-normal

font-weight

See the font weight tokens for details.

Custom PropertyClassShort class
--extra-light.font-extra-light.extra-light
--light.font-light.light
--book.font-book.book
--semi-bold.font-semi-bold.semi-bold
--bold.font-bold.bold
--black.font-black.black

font-size

See the font size tokens for details.

Custom PropertyClass
--text-xs.text-xs
--text-sm.text-sm
--text-dm.text-dm
--text-lg.text-lg
--text-xl.text-xl
--display-sm.display-sm
--display-md.display-md
--display-lg.display-lg
--display-xl.display-xl

line-height

See the line height tokens for details.

Custom PropertyClass
--leading-xs.leading-xs
--leading-sm.leading-sm
--leading-md.leading-md
--leading-lg.leading-lg
--leading-xl.leading-xl
--leading-xxl.leading-xxl

text-align

CSS valueClass
left.text-left
center.text-center
right.text-right
justify.text-justify
start.text-start
end.text-end

text-transform

CSS valueClass
uppercase.text-uppercase
lowercase.text-lowercase
capitalize.text-capitalize