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-padding-safe

v1.0.6

Published

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

Downloads

2,092

Readme

Tailwind CSS Padding Safe Plugin

This plugin is based on the tailwindcss framework. Usage is similar to the core padding plugin, but outputs px-[value]-safe padding, instead of px-[value]. This is my first package so don't hesitate to point me on any improvement or issue.

Installation

npm install -D tailwindcss-padding-safe

Usage

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

This plugin generates the following utilities:

  • the same with m prefix for margin
/* Default rules for browser without max() support same as core padding generated rules */

.p-[value]-safe {
	padding: [value]rem;
}
.py-[value]-safe {
	padding-top: [value]rem;
	padding-bottom: [value]rem;
}
.px-[value]-safe {
	padding-left: [value]rem;
	padding-right: [value]rem;
}
.pt-[value]-safe {
	padding-top: [value]rem;
}
.pb-[value]-safe {
	padding-bottom: [value]rem;
}
.pl-[value]-safe {
	padding-left: [value]rem;
}
.pr-[value]-safe {
	padding-right: [value]rem;
}

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

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

Options

It's working out of the box with your current padding 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: {
    paddingSafe:{
      padding: {
        '1': '1rem',
      },
      suffix: {
        'notch'
      },
      onlySupportsRules : true
    },
},
variants: {
  paddingSafe: [ 'responsive' ],
},

theme.paddingSafe.padding is optional and it defaults to theme.padding theme.paddingSafe.suffix is optional and it defaults to "safe" theme.paddingSafe.onlySupportsRules is optional and it defaults to false variants.paddingSafe is optional and it defaults to variants.padding

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 padding for browser without support, so you should add default core padding 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'