Add margin, padding and inset safe area utilities#6366
Conversation
|
I think it could also be useful to have utilities for having a specific margin value that also takes into account the safe area. I've decided to leave those out of this MR though because of the additional complexity. For example, you In order of what I think makes sense: .ml-4-safe {
margin-left: calc(env(safe-area-inset-left) + 1rem)
}or .ml-4-safe {
margin-left: max(env(safe-area-inset-left), 1rem)
}or (can't personally see a use case for this one but I might be missing something) .ml-4-safe {
margin-left: min(env(safe-area-inset-left), 1rem)
}If this is wanted to be added, it's potentially worth having a utility like |
|
Hey thanks for this! I am not totally sure on the absolute best way to handle this — I don't think creating all new core plugins for just these values is the way to go though. It's tricky though as I suspect you discovered because we don't really have a mechanism for allowing a single key (like My gut is that a more powerful/flexible solution here is to create four new values that would be part of the config. In user-land it would look like this: module.exports = {
theme: {
extend: {
margin: {
'safe-top': 'env(safe-area-inset-top)',
'safe-right': 'env(safe-area-inset-right)',
'safe-bottom': 'env(safe-area-inset-bottom)',
'safe-left': 'env(safe-area-inset-left)',
}
}
}
}It's not quite as short or clean since you'd need to say I'm still not 100% sure that's the absolute best approach either so even if we explore a new PR for that I think we will still have to think it through, but I'm going to close this PR as I don't think this is the approach I would like to use in core. Totally feel free to open another PR based on my comments here if you like though 👍 And thanks as always for the contribution, appreciate it even if it's not being merged in ❤️ |
This MR adds safe area inset utilities for margin, padding and inset. This is particularly useful when designing for notched iPhones.