home / skills / applelamps / x-vercel-beta / mobile-ui

mobile-ui skill

/.claude/skills/mobile-ui

This skill helps you optimize mobile UI for responsive layouts, safe areas, touch targets, and typography across iPhone models.

npx playbooks add skill applelamps/x-vercel-beta --skill mobile-ui

Review the files below or copy the command above to add this skill to your agents.

Files (8)
SKILL.md
3.7 KB
---
name: mobile-ui-optimization
description: Optimizes mobile UI for smartphones including iPhone 16/17/18 Pro. Use when building responsive layouts, touch interfaces, mobile viewports, safe areas, or when user mentions mobile, smartphone, iPhone, responsive design, or touch targets.
---

# Mobile UI Optimization

## Quick Reference

### Viewport Setup

```html
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
```

### Safe Areas (iPhone Dynamic Island & Notch)

```css
:root {
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);
  --safe-area-left: env(safe-area-inset-left);
  --safe-area-right: env(safe-area-inset-right);
}

body {
  padding-top: var(--safe-area-top);
  padding-bottom: var(--safe-area-bottom);
  padding-left: var(--safe-area-left);
  padding-right: var(--safe-area-right);
}
```

### Touch Target Minimums

- **Minimum size**: 44×44px (Apple HIG) / 48×48dp (Material Design)
- **Recommended**: 48×48px with 8px spacing between targets
- **Critical actions**: 56×56px minimum

### Typography Scale

```css
:root {
  --text-xs: clamp(0.75rem, 2.5vw, 0.875rem);   /* 12-14px */
  --text-sm: clamp(0.875rem, 3vw, 1rem);        /* 14-16px */
  --text-base: clamp(1rem, 3.5vw, 1.125rem);    /* 16-18px */
  --text-lg: clamp(1.125rem, 4vw, 1.25rem);     /* 18-20px */
  --text-xl: clamp(1.25rem, 4.5vw, 1.5rem);     /* 20-24px */
  --text-2xl: clamp(1.5rem, 5vw, 2rem);         /* 24-32px */
}
```

## Device Breakpoints

| Device | Width | Pixel Ratio |
|--------|-------|-------------|
| iPhone SE | 375px | 2x |
| iPhone 14/15/16 | 390px | 3x |
| iPhone 14/15/16 Pro | 393px | 3x |
| iPhone 14/15/16 Plus | 428px | 3x |
| iPhone 14/15/16 Pro Max | 430px | 3x |
| iPhone 17/18 Pro (expected) | 393-402px | 3x |

### Tailwind Breakpoints

```js
// tailwind.config.js
screens: {
  'xs': '375px',    // iPhone SE, small phones
  'sm': '390px',    // iPhone 14/15/16 base
  'md': '430px',    // iPhone Pro Max, large phones
  'lg': '768px',    // Tablets
  'xl': '1024px',   // Desktop
}
```

## Core Patterns

### 1. Responsive Container

```tsx
<div className="w-full max-w-screen-sm mx-auto px-4 
  pt-[env(safe-area-inset-top)] 
  pb-[env(safe-area-inset-bottom)]">
  {children}
</div>
```

### 2. Bottom Navigation (iOS Home Indicator Safe)

```tsx
<nav className="fixed bottom-0 left-0 right-0 
  bg-white border-t border-gray-200
  pb-[env(safe-area-inset-bottom)]">
  <div className="flex justify-around py-2">
    {/* Nav items with min-h-[44px] */}
  </div>
</nav>
```

### 3. Touch-Optimized Button

```tsx
<button className="min-h-[44px] min-w-[44px] px-4 py-3
  active:scale-95 transition-transform
  touch-manipulation">
  {label}
</button>
```

### 4. Scroll Container (Momentum Scrolling)

```tsx
<div className="overflow-y-auto overscroll-contain
  -webkit-overflow-scrolling: touch
  scroll-snap-type-y-mandatory">
  {children}
</div>
```

## Critical Rules

1. **NEVER** use `user-scalable=no` or `maximum-scale=1` - breaks accessibility
2. **ALWAYS** use `touch-manipulation` on interactive elements to remove 300ms delay
3. **ALWAYS** account for Dynamic Island/notch with `env(safe-area-inset-*)`
4. **NEVER** rely on hover states for critical interactions
5. **ALWAYS** provide visible focus states for keyboard/assistive technology users

## Detailed Guides

- **Viewport & Safe Areas**: See [VIEWPORT.md](VIEWPORT.md)
- **Touch Interactions**: See [TOUCH.md](TOUCH.md)
- **Typography & Readability**: See [TYPOGRAPHY.md](TYPOGRAPHY.md)
- **Performance**: See [PERFORMANCE.md](PERFORMANCE.md)
- **Forms & Inputs**: See [FORMS.md](FORMS.md)
- **Navigation Patterns**: See [NAVIGATION.md](NAVIGATION.md)
- **Testing Checklist**: See [TESTING.md](TESTING.md)

Overview

This skill optimizes mobile UI for smartphones including iPhone 16/17/18 Pro, focusing on responsive layouts, safe areas, touch targets, and mobile viewport setup. It provides concrete patterns, breakpoints, and CSS/TypeScript snippets to make interfaces feel native, accessible, and robust across modern iPhones and high-density displays. Use it to reduce common mobile layout issues and improve touch/visual ergonomics.

How this skill works

The skill inspects layout and interaction patterns and suggests adjustments for viewport meta, safe-area insets, touch target sizing, typography scaling, and scrolling behavior. It recommends device-aware breakpoints and Tailwind config mappings, supplies core component patterns (responsive container, bottom nav, touch-optimized buttons, momentum scroll), and enforces critical accessibility rules. Outputs are actionable changes and code patterns you can drop into TypeScript/React projects.

When to use it

  • Building or testing responsive layouts for smartphones
  • Designing touch interfaces and navigation for iOS/Android
  • Targeting iPhone 16/17/18 Pro or other high-density phones
  • Implementing safe-area support for notches and Dynamic Island
  • Improving mobile typography, spacing, and touch target sizes

Best practices

  • Include a proper viewport meta tag with viewport-fit=cover to enable safe-area use
  • Apply env(safe-area-inset-*) to padding/margins for top/bottom/left/right safe areas
  • Use minimum touch target sizes (44×44px Apple / 48×48dp Material); prefer 48×48px with 8px spacing
  • Avoid disabling zoom (never use user-scalable=no or maximum-scale=1) to preserve accessibility
  • Provide visible focus states and never rely on hover for critical actions
  • Enable touch-manipulation and momentum scrolling for native-feeling interactions

Example use cases

  • Add safe-area-aware padding to a full-width app shell so content doesn’t collide with Dynamic Island or the home indicator
  • Create a bottom navigation bar with pb using env(safe-area-inset-bottom) and nav items sized to at least 44–56px
  • Apply a responsive typography scale using clamp() to keep text readable across iPhone SE to Pro Max
  • Configure Tailwind screens to match common iPhone widths and serve optimized layouts per breakpoint
  • Build a scroll container with -webkit-overflow-scrolling: touch and scroll-snap to deliver smooth momentum scrolling

FAQ

Will these patterns break desktop layouts?

No. Patterns use responsive breakpoints and max-width containers so desktop styles remain intact; safe-area insets do nothing on non-safe-area devices.

What touch target size should I choose for critical actions?

Use at least 56×56px for critical actions, 48×48px as a recommended default, and never go below 44×44px for tappable controls.

How do I support older devices with notches or no safe-area env values?

env(safe-area-inset-*) falls back to 0 on devices that don’t expose them. Combine with sensible default padding and test on physical devices or simulators.