You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That PR was closed because this is a significant API addition and should be discussed before implementation. Opening this discussion to agree on the right shape before sending another PR.
Problem
Tailwind has great primitives for spacing, inset positioning, scroll padding/margin, and modern viewport units like dvh/svh/lvh, but it does not currently have a first-class way to use the platform safe-area insets:
Those values are necessary when a web UI is allowed to use the full device viewport. This affects:
installed PWAs using display: fullscreen or app-like standalone display modes
iOS/Safari layouts using viewport-fit=cover
Capacitor, Cordova, Ionic, and other native shells where the WebView can render under the status bar, navigation bar, notch, camera cutout, or home indicator
Android edge-to-edge apps where system bars overlay the WebView
Without safe-area utilities, Tailwind users have to repeatedly write custom CSS or install a larger UI library/plugin only to get a small set of layout primitives. Libraries like Ionic/Konsta-style mobile UI kits commonly include safe-area helpers because the problem is not component-specific; it is a viewport layout primitive.
Why this matters in practice
In a fullscreen WebView or PWA, regular Tailwind utilities can place UI behind unsafe screen areas:
This part is optional, but it helps when a root app shell consumes the safe area and nested components should not double-apply it.
Questions for maintainers
Is this feature appropriate for core, given that Tailwind already includes viewport-unit utilities and scroll padding/margin utilities?
Should the API be direct utilities like pt-safe / pt-safe-4, or a modifier-like shape such as safe:pt-4?
For combined spacing, should the math be calc(env(...) + spacing) by default, or should there also be a max(env(...), spacing) form?
Should the first version be limited to padding/inset/viewport sizes to keep scope small, then expand to margin and scroll utilities later?
How should Tailwind handle physical vs logical axes here? The platform exposes physical safe-area values (left/right), but Tailwind also has logical spacing utilities (ps/pe).
If maintainers agree on the API direction, I am happy to adapt the closed implementation from #19921 into a smaller PR that matches the chosen shape.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Related PR: #19921
That PR was closed because this is a significant API addition and should be discussed before implementation. Opening this discussion to agree on the right shape before sending another PR.
Problem
Tailwind has great primitives for spacing, inset positioning, scroll padding/margin, and modern viewport units like
dvh/svh/lvh, but it does not currently have a first-class way to use the platform safe-area insets:Those values are necessary when a web UI is allowed to use the full device viewport. This affects:
display: fullscreenor app-like standalone display modesviewport-fit=coverWithout safe-area utilities, Tailwind users have to repeatedly write custom CSS or install a larger UI library/plugin only to get a small set of layout primitives. Libraries like Ionic/Konsta-style mobile UI kits commonly include safe-area helpers because the problem is not component-specific; it is a viewport layout primitive.
Why this matters in practice
In a fullscreen WebView or PWA, regular Tailwind utilities can place UI behind unsafe screen areas:
On devices with notches, rounded corners, system gesture areas, or overlaid status/navigation bars, this often needs extra CSS:
The need is even stronger when an element already has design spacing and also needs the safe inset:
Expected output could be:
This is awkward to maintain manually across padding, margin, inset, scroll-padding, scroll-margin, height, and width utilities.
Existing demand
This has come up several times already:
The web platform also treats this as a standard CSS environment value, not a framework-specific workaround:
env()/ safe-area inset docs: https://developer.mozilla.org/en-US/docs/Web/CSS/envviewport-fit=cover/ safe-area guidance: https://webkit.org/blog/7929/designing-websites-for-iphone-x/displaymodes: https://developer.mozilla.org/docs/Web/Progressive_web_apps/Manifest/Reference/displayPossible API
I am not attached to the exact naming from the PR, but this is the shape I think would cover the real use cases while staying Tailwind-like.
Direct safe-area spacing
These would map directly to the relevant
env(safe-area-inset-*)value.Safe-area plus theme spacing
This would mean "safe inset plus the normal Tailwind spacing value", for example:
This is the most common app-shell case: preserve normal design spacing, then add the device inset only when it exists.
Safe viewport sizes
Vertical safe sizes subtract top/bottom safe areas. Width variants are useful in landscape where safe areas are on the left/right edges:
Optional reset/scope utilities
If the implementation uses internal custom properties, reset utilities could make component subtrees easier to control:
This part is optional, but it helps when a root app shell consumes the safe area and nested components should not double-apply it.
Questions for maintainers
pt-safe/pt-safe-4, or a modifier-like shape such assafe:pt-4?calc(env(...) + spacing)by default, or should there also be amax(env(...), spacing)form?left/right), but Tailwind also has logical spacing utilities (ps/pe).If maintainers agree on the API direction, I am happy to adapt the closed implementation from #19921 into a smaller PR that matches the chosen shape.
Beta Was this translation helpful? Give feedback.
All reactions