npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

postcss-preset-mantine

v1.18.0

Published

PostCSS preset for Mantine (7.0+) applications

Readme

postcss-preset-mantine

Documentation

Installation

yarn add --dev postcss postcss-preset-mantine postcss-simple-vars

Usage

Add postcss-preset-mantine to your postcss.config.js config:

module.exports = {
  plugins: {
    'postcss-preset-mantine': {},
    'postcss-simple-vars': {
      variables: {
        'mantine-breakpoint-xs': '36em',
        'mantine-breakpoint-sm': '48em',
        'mantine-breakpoint-md': '62em',
        'mantine-breakpoint-lg': '75em',
        'mantine-breakpoint-xl': '88em',
      },
    },
  },
};

rem/em functions

rem and em functions can be used to convert pixels to rem/em units. 16px = 1rem and 16px = 1em, em values are supposed to be used in media queries, rem everywhere else. You can learn more about units conversions in this guide.

.demo {
  font-size: rem(16px);

  @media (min-width: em(320px)) {
    font-size: rem(32px);
  }
}

Will be transformed to:

.demo {
  font-size: calc(1rem * var(--mantine-scale));

  @media (min-width: 20em) {
    font-size: calc(2rem * var(--mantine-scale));
  }
}

dark and light mixins

dark and light mixins can be used to create styles that will be applied only in dark or light color scheme.

.demo {
  @mixin light {
    color: red;
  }

  @mixin dark {
    color: blue;
  }
}

Will be transformed to:

[data-mantine-color-scheme='light'] .demo {
  color: red;
}

[data-mantine-color-scheme='dark'] .demo {
  color: blue;
}

Note that usually you do not need to use both light and dark mixins at the same time. It is easier to define styles for light color scheme and then use dark mixin to override them in dark color scheme.

.demo {
  // Value for light color scheme
  color: red;

  @mixin dark {
    // Value for dark color scheme
    color: blue;
  }
}

To define values for light/dark color scheme on the :root/html element, use light-root and dark-root mixins instead:

:root {
  @mixin light-root {
    --color: red;
  }

  @mixin dark-root {
    --color: blue;
  }
}

smaller-than and larger-than mixins

smaller-than and larger-than mixins can be used to create styles that will be applied only when screen is smaller or larger than specified breakpoint.

.demo {
  @mixin smaller-than 320px {
    color: red;
  }

  @mixin larger-than 320px {
    color: blue;
  }
}

Will be transformed to:

// Breakpoint values are converted to em units
// In smaller-than mixin 0.1px is subtracted from breakpoint value
// to avoid intersection with larger-than mixin
@media (max-width: 19.99375em) {
  .demo {
    color: red;
  }
}

@media (min-width: 20em) {
  .demo {
    color: blue;
  }
}

You can also use smaller-than and larger-than mixins with mantine breakpoints:

.demo {
  @mixin smaller-than $mantine-breakpoint-sm {
    color: red;
  }

  @mixin larger-than $mantine-breakpoint-sm {
    color: blue;
  }
}

light-dark function

light-dark function is an alternative to light and dark mixins. It accepts two arguments: first argument is rule that will be applied in light color scheme, second argument is rule that will be applied in dark color scheme.

.demo {
  color: light-dark(red, blue);
}

Will be transformed to:

.demo {
  color: red;
}

[data-mantine-color-scheme='dark'] .demo {
  color: blue;
}

light-dark with html and :root selectors

Note that light-dark function does not work on :root/html element. Use light-root and dark-root mixins instead:

// ❌ Does not work
:root {
  --color: light-dark(red, blue);
}

// ✅ Works
:root {
  @mixin light-root {
    --color: red;
  }

  @mixin dark-root {
    --color: blue;
  }
}

light-dark and !important

!important at rule level:

.button {
  color: light-dark(red, blue) !important;
}

// Is transformed to
.button {
  background: red !important;
}

[data-mantine-color-scheme='dark'] .button {
  background: blue !important;
}

!important at value level:

// !important at value level
.button {
  color: light-dark(red !important, blue);
}

// Is transformed to
.button {
  background: red !important;
}

[data-mantine-color-scheme='dark'] .button {
  background: blue;
}

alpha function

alpha function can be used to add alpha channel to color. Note that it uses color-mix which is not supported in some older browsers.

.demo {
  color: alpha(var(--mantine-color-red-4), 0.5);
  border: 1px solid alpha(#ffc, 0.2);
}

Will be transformed to:

.demo {
  color: color-mix(in srgb, var(--mantine-color-red-4), transparent 50%);
  border: 1px solid color-mix(in srgb, #ffc, transparent 80%);
}

lighten and darken functions

lighten and darken functions work similar to alpha function, but instead of adding alpha channel they add white or black color to the color with color-mix.

.demo {
  color: lighten(var(--mantine-color-red-4), 0.5);
  border: 1px solid darken(#ffc, 0.2);
}

Will be transformed to:

.demo {
  color: color-mix(in srgb, var(--mantine-color-red-4), white 50%);
  border: 1px solid color-mix(in srgb, #ffc, black 20%);
}

hover mixin

hover mixin can be used to create styles that will be applied on hover.

.demo {
  @mixin hover {
    color: orange;
  }
}

Will be transformed to:

@media (hover: hover) {
  .demo:hover {
    color: orange;
  }
}

@media (hover: none) {
  .demo:active {
    color: orange;
  }
}

rtl/ltr mixins

rtl mixin can be used to create styles that will be applied when dir="rtl" is set on parent element (usually <html />).

.demo {
  margin-left: 1rem;

  @mixin rtl {
    margin-left: 0;
    margin-right: 1rem;
  }
}

Will be transformed to:

.demo {
  margin-left: 1rem;
}

[dir='rtl'] .demo {
  margin-left: 0;
  margin-right: 1rem;
}

ltr mixin works the same way, but for dir="ltr":

.demo {
  margin-left: 1rem;

  @mixin ltr {
    margin-left: 0;
    margin-right: 1rem;
  }
}

Will be transformed to:

.demo {
  margin-left: 1rem;
}

[dir='ltr'] .demo {
  margin-left: 0;
  margin-right: 1rem;
}

not-rtl/not-ltr mixins

not-rtl/not-ltr mixins can be used to create styles that will be applied when the direction is set to the opposite value or not set at all. For example, not-rtl styles will be applied when dir="ltr" or when dir is not set at all.

.demo {
  @mixin not-rtl {
    margin-right: 1rem;
  }
}

Will be transformed to:

:root:not([dir='rtl']) .demo {
  margin-right: 1rem;
}

License

MIT License