Created
July 26, 2021 15:51
-
-
Save th3hamburgler/c9bec81954ec0b99ad7a8658a6c352fb to your computer and use it in GitHub Desktop.
Tailwind safe area inset utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@layer utilities { | |
/* extra helper classes to account for mobile safe areas */ | |
.p-safe { | |
padding: env(safe-area-inset-top) env(safe-area-inset-right) | |
env(safe-area-inset-bottom) env(safe-area-inset-left); | |
} | |
.px-safe { | |
padding-left: env(safe-area-inset-left); | |
padding-right: env(safe-area-inset-right); | |
} | |
.py-safe { | |
padding-top: env(safe-area-inset-top); | |
padding-bottom: env(safe-area-inset-bottom); | |
} | |
.pt-safe { | |
padding-top: env(safe-area-inset-top); | |
} | |
.pr-safe { | |
padding-right: env(safe-area-inset-right); | |
} | |
.pb-safe { | |
padding-bottom: env(safe-area-inset-bottom); | |
} | |
.pl-safe { | |
padding-left: env(safe-area-inset-right); | |
} | |
.m-safe { | |
margin: env(safe-area-inset-top) env(safe-area-inset-right) | |
env(safe-area-inset-bottom) env(safe-area-inset-left); | |
} | |
.mx-safe { | |
margin-left: env(safe-area-inset-left); | |
margin-right: env(safe-area-inset-right); | |
} | |
.my-safe { | |
margin-top: env(safe-area-inset-top); | |
margin-bottom: env(safe-area-inset-bottom); | |
} | |
.mt-safe { | |
margin-top: env(safe-area-inset-top); | |
} | |
.mr-safe { | |
margin-right: env(safe-area-inset-right); | |
} | |
.mb-safe { | |
margin-bottom: env(safe-area-inset-bottom); | |
} | |
.ml-safe { | |
margin-left: env(safe-area-inset-right); | |
} | |
.top-safe { | |
top: 0; | |
top: env(safe-area-inset-top); | |
} | |
.right-safe { | |
right: 0; | |
right: env(safe-area-inset-right); | |
} | |
.bottom-safe { | |
bottom: 0; | |
bottom: env(safe-area-inset-bottom); | |
} | |
.left-safe { | |
left: 0; | |
left: env(safe-area-inset-right); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment