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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tailwindcss-margin-safe

v1.0.1

Published

Tailwind CSS plugin to generate margin utilities with safe-area-inset.

Downloads

32

Readme

Tailwind CSS Margin Safe Plugin

This plugin is based on the tailwindcss framework. Usage is similar to the core margin plugin, but outputs mx-[value]-safe margin, instead of mx-[value].

This packaged is an edited fork from the excellent work at https://github.com/desaintflorent/tailwindcss-padding-safe

Installation

npm install tailwindcss-margin-safe

Usage

// In your Tailwind JS config
{
	plugins: [require("tailwindcss-margin-safe")()]
}

This plugin generates the following utilities:

/* Default rules for browser without max() support same as core margin generated rules */

.m-[value]-safe {
	margin: [value]rem;
}
.my-[value]-safe {
	margin-top: [value]rem;
	margin-bottom: [value]rem;
}
.mx-[value]-safe {
	margin-left: [value]rem;
	margin-right: [value]rem;
}
.mt-[value]-safe {
	margin-top: [value]rem;
}
.mb-[value]-safe {
	margin-bottom: [value]rem;
}
.ml-[value]-safe {
	margin-left: [value]rem;
}
.mr-[value]-safe {
	margin-right: [value]rem;
}

/* Safe area rules for browser with max() support */

@supports (margin: max(0px)) {
	.p-[value]-safe {
		margin-top: max([value]rem, env(safe-area-inset-top));
		margin-bottom: max([value]rem, env(safe-area-inset-bottom));
		margin-left: max([value]rem, env(safe-area-inset-left));
		margin-right: max([value]rem, env(safe-area-inset-right));
	}
	.py-[value]-safe {
		margin-top: max([value]rem, env(safe-area-inset-top));
		margin-bottom: max([value]rem, env(safe-area-inset-bottom));
	}
	.px-[value]-safe {
		margin-left: max([value]rem, env(safe-area-inset-left));
		margin-right: max([value]rem, env(safe-area-inset-right));
	}
	.pt-[value]-safe {
		margin-top: max([value]rem, env(safe-area-inset-top));
	}
	.pb-[value]-safe {
		margin-bottom: max([value]rem, env(safe-area-inset-bottom));
	}
	.pl-[value]-safe {
		margin-left: max([value]rem, env(safe-area-inset-left));
	}
	.pr-[value]-safe {
		margin-right: max([value]rem, env(safe-area-inset-right));
	}
}

Options

It's working out of the box with your current margin options ! ( Pro tip : use purgecss ) But if you need, you can set options in your tailwindcss.js like this :

// In your Tailwind CSS config
theme: {
    marginSafe:{
      margin: {
        '1': '1rem',
      },
      suffix: {
        'notch'
      },
      onlySupportsRules : true
    },
},
variants: {
  marginSafe: [ 'responsive' ],
},

theme.marginSafe.margin is optional and it defaults to theme.margin theme.marginSafe.suffix is optional and it defaults to "safe" theme.marginSafe.onlySupportsRules is optional and it defaults to false variants.marginSafe is optional and it defaults to variants.margin

Use it in your html like this :

<div class="pt-1-safe">Example of block</div>

If you don't want to generate default rules for browser without support for max(), you can set the onlySupportsRules option to true. But then, you will not get any margin for browser without support, so you should add default core margin too :

<div class="pt-1 pt-1-safe">Example of block</div>

Warning

Unitless values inside max() are considered invalid. So if you define custom value in your theme option, keep in mind that you need to use a unit with your value like this :

   '1': '1rem', //not '1': '1'

Or

   '0': '0px', //not '0': '0'