Update capacitor skill for Tailwind v4 safe-area plugin

The previous version pinned tailwindcss-safe-area to 0.8.0 and walked
through registering it in a tailwind.config.ts plugins array. mkstack
now ships Tailwind v4 with CSS-first config (@import "tailwindcss"
in src/index.css, no tailwind.config.ts), and the plugin's v1.x line
has switched from a JS plugin entry point to a plain CSS file consumed
via @import — using @plugin fails to resolve.

Updates:
- Install step now pulls the latest tailwindcss-safe-area (1.x) with
  a note that v3 projects still need 0.8.0 + plugins array.
- Step 3 replaces the tailwind.config.ts edit with an @import line in
  src/index.css, placed after @import "tailwindcss".
- Troubleshooting entries for WebView <140 and 'pt-safe does not
  exist' rewritten to reference the CSS import model.
- Utilities table refreshed to match the v4 README (adds border-*-safe,
  h-svh-safe/h-lvh-safe/h-vh-safe/h-fill-safe, start/end logical
  variants, and the safe/safe-none enable-disable toggles).
- safe-area-shim.css header updated to show the v4 import order
  (@import "tailwindcss-safe-area"; then @import "./safe-area-shim.css")
  instead of the old @tailwind utilities directive.
This commit is contained in:
Alex Gleason committed 2026-04-26 22:00:13 -05:00
1 parent e0f6a061b4
commit 924d430310
2 files changed
+42 -52

No files matched your search

+36 -45
View File
@@ -74,24 +74,13 @@ npm install @capacitor/core @capacitor/app @capacitor/filesystem \
# Capacitor toolchain (dev)
npm install -D @capacitor/cli @capacitor/android @capacitor/ios
# Safe-area Tailwind plugin — VERSION DEPENDS ON YOUR TAILWIND MAJOR:
# Tailwind v3 (this project): [email protected] (last v3-compat release)
# Tailwind v4 (newer stacks): tailwindcss-safe-area@latest (>=1.0.0)
npm install -D [email protected]
# Safe-area utilities (Tailwind v4 — this project)
npm install -D tailwindcss-safe-area
```
**Why the pinned version for `tailwindcss-safe-area`?** The plugin's API
changed between v0.x and v1.x to match Tailwind's own v3→v4 transition:
mkstack ships **Tailwind v4** with a CSS-first configuration (`@import "tailwindcss"` in `src/index.css`, no `tailwind.config.ts`). The safe-area plugin is registered via a CSS import, not a JS plugins array — see step 3.
| Plugin version | Tailwind version | How to register |
|---|---|---|
| `^0.8.0` | 3.x | Import in `tailwind.config.ts` as a plugin (this project) |
| `>=1.0.0` | 4.x | `@import "tailwindcss-safe-area";` in your main CSS |
mkstack ships Tailwind **3.4.x**, so pin to `0.8.0`. Using `@latest`
on a Tailwind v3 project silently produces no utilities. If you later
upgrade the project to Tailwind v4, bump this dependency at the same
time and switch from the `plugins:` array to a CSS `@import`.
If you're porting these instructions to a Tailwind v3 project, install `[email protected]` instead and register it in `tailwind.config.ts`'s `plugins` array. On v4 the `0.8.0` version emits no utilities.
Each runtime package:
@@ -117,26 +106,24 @@ Each runtime package:
Copy every file listed in the tables above from
`.agents/skills/capacitor/files/` into its corresponding location.
### 3. Register the Tailwind Safe-Area Plugin
### 3. Register the Safe-Area Plugin (Tailwind v4 CSS import)
Edit `tailwind.config.ts` to import the plugin and append it to the
`plugins` array:
Add a second `@import` line to `src/index.css`, directly after the existing `@import "tailwindcss";`:
```ts
// tailwind.config.ts
import type { Config } from "tailwindcss";
import tailwindcssAnimate from "tailwindcss-animate";
import safeArea from "tailwindcss-safe-area"; // add this
```css
/* src/index.css */
@import "tailwindcss";
@import "tailwindcss-safe-area";
@import "tw-animate-css";
export default {
// ...existing config...
plugins: [tailwindcssAnimate, safeArea], // append safeArea
} satisfies Config;
/* …existing @theme, @custom-variant, @layer rules unchanged… */
```
**Use `@import`, not `@plugin`.** The safe-area package ships a plain CSS file for Tailwind v4, not a JS plugin entry point — `@plugin "tailwindcss-safe-area";` will fail to resolve.
This unlocks utilities like `pt-safe`, `pb-safe`, `px-safe`, `top-safe`,
`bottom-safe`, `h-dvh-safe`, `min-h-dvh-safe`, plus the `-offset-{n}` /
`-or-{n}` variants (e.g. `pb-safe-offset-4` = safe area + 1rem;
`bottom-safe`, `h-dvh-safe`, `min-h-dvh-safe`, `border-t-safe`, plus the
`-offset-{n}` and `-or-{n}` variants (e.g. `pb-safe-offset-4` = safe area + 1rem;
`pb-safe-or-8` = max of safe area and 2rem). See the plugin's
[README](https://github.com/mvllow/tailwindcss-safe-area) for the full
utility list.
@@ -359,16 +346,20 @@ Common utilities:
| Utility | Meaning |
|---|---|
| `pt-safe`, `pr-safe`, `pb-safe`, `pl-safe` | Padding on one side |
| `pt-safe`, `pr-safe`, `pb-safe`, `pl-safe`, `ps-safe`, `pe-safe` | Padding on one side (physical + logical) |
| `px-safe`, `py-safe`, `p-safe` | Padding on multiple sides |
| `mt-safe`, …, `m-safe` | Margin equivalents |
| `top-safe`, `bottom-safe`, `left-safe`, `right-safe` | Absolute / fixed positioning |
| `mt-safe`, …, `m-safe`, `ms-safe`, `me-safe` | Margin equivalents |
| `top-safe`, `bottom-safe`, `left-safe`, `right-safe`, `start-safe`, `end-safe` | Absolute / fixed positioning |
| `inset-safe`, `inset-x-safe`, `inset-y-safe` | All-side inset |
| `h-dvh-safe`, `min-h-dvh-safe`, `max-h-dvh-safe` | Dynamic viewport height minus insets |
| `border-t-safe`, …, `border-safe`, `border-x-safe`, `border-y-safe` | Border width sized to the inset |
| `h-dvh-safe`, `h-svh-safe`, `h-lvh-safe`, `h-vh-safe` | Viewport heights minus insets (dynamic / small / large / static) |
| `min-h-dvh-safe`, `max-h-dvh-safe`, etc. | min/max variants of the above |
| `h-screen-safe` | Classic viewport height minus insets |
| `h-fill-safe` | `-webkit-fill-available` minus insets |
| `{prop}-safe-offset-{n}` | Safe area + `{n}` (e.g. `pb-safe-offset-4`) |
| `{prop}-safe-or-{n}` | `max(safe-area, {n})` (e.g. `pb-safe-or-8`) |
| `scroll-p-safe`, `scroll-m-safe`, … | Scroll padding / margin |
| `safe`, `safe-x`, `safe-y`, `safe-t`, …, `safe-none`, … | Toggle safe-area handling on/off per axis or side |
See the [plugin README](https://github.com/mvllow/tailwindcss-safe-area)
for the full list.
@@ -407,23 +398,23 @@ for the full list.
`env(safe-area-inset-*)` as `0`. The `SystemBars` plugin with
`insetsHandling: 'css'` (already set in the skill's
`capacitor.config.ts`) injects `--safe-area-inset-*` CSS variables
with the correct values, but the `tailwindcss-safe-area@0.8.0`
plugin uses `env(…)` directly and can't see them. Two fixes:
with the correct values, but the `tailwindcss-safe-area` package
emits rules that use `env(…)` directly and can't see them. Two fixes:
1. **Preferred:** ensure your target Android devices are on WebView
140+ (released Aug 2025). Any actively-updated Android >=7 should
be, since WebView auto-updates via Play Services.
2. **Fallback:** copy `files/safe-area-shim.css` into `src/` and
`@import` it after `@tailwind utilities;` in `src/index.css` —
it re-declares the common utilities with
`@import` it **after** `@import "tailwindcss-safe-area";` in
`src/index.css` — it re-declares the common utilities with
`var(--safe-area-inset-*, env(…, 0px))` so the SystemBars-injected
variables take over when `env()` reports 0. See the file's header
comment for details.
- **`pt-safe` doesn't exist at all** — the Tailwind plugin isn't
registered. Verify `import safeArea from "tailwindcss-safe-area"` and
that `safeArea` is listed in the `plugins` array of
`tailwind.config.ts`. Also verify you installed the **0.8.0** version
specifically (`npm ls tailwindcss-safe-area`). Version `1.x` is for
Tailwind v4 and emits no utilities on v3.
variables take over when `env()` reports 0.
- **`pt-safe` doesn't exist at all** — the CSS import is missing or
in the wrong position. Verify `src/index.css` contains
`@import "tailwindcss-safe-area";` **after** `@import "tailwindcss";`
(source order matters in Tailwind v4). Also verify you installed the
v4-compatible version: `npm ls tailwindcss-safe-area` should show
`>=1.0.0`. Version `0.8.0` is a JS plugin for Tailwind v3 and emits
nothing on v4.
- **Safe-area utilities have 0px on iOS Safari/Xcode simulator** —
missing `viewport-fit=cover` in your `<meta name="viewport">` tag.
Without it iOS doesn't expose the insets.
@@ -22,15 +22,14 @@
* may still be running WebView <140. On iOS and on Android 140+ the
* plugin's output works correctly and this shim is redundant.
*
* How to include:
* How to include (Tailwind v4, CSS-first config):
* 1. Copy this file to `src/safe-area-shim.css`
* 2. Import it in `src/index.css` AFTER the `@tailwind utilities;`
* directive so these rules win via source order:
* 2. Import it in `src/index.css` AFTER `@import "tailwindcss-safe-area";`
* so source order lets these rules win within the utilities layer:
*
* @tailwind base;
* @tailwind components;
* @tailwind utilities;
* @import './safe-area-shim.css';
* @import "tailwindcss";
* @import "tailwindcss-safe-area";
* @import "./safe-area-shim.css";
*
* Uses `@layer utilities` so these rules sit in the same cascade layer as
* the Tailwind utilities they're overriding; later-declared rules within