tailwindcss-mobile-first

安装量: 903
排名: #1443

安装

npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill tailwindcss-mobile-first

Mobile-First Responsive Design (2025/2026) Core Philosophy

Mobile-first design is the industry standard for 2025/2026. With mobile traffic consistently exceeding 60% of global web traffic and Google's mobile-first indexing, starting with mobile ensures optimal user experience and SEO performance.

The Mobile-First Mindset

Start small, enhance upward
Starts large, reduces down (more code, more bugs)

Key Principle: Unprefixed utilities apply to ALL screen sizes. Breakpoint prefixes apply at that size AND ABOVE.

2025/2026 Breakpoint Strategy Tailwind's Default Breakpoints Prefix Min-width Target Devices (none) 0px All mobile phones (base) sm: 640px (40rem) Large phones, small tablets md: 768px (48rem) Tablets (portrait) lg: 1024px (64rem) Tablets (landscape), laptops xl: 1280px (80rem) Desktops 2xl: 1536px (96rem) Large desktops Content-Driven Breakpoints

Best Practice 2025/2026: Let content determine breakpoints, not device dimensions.

@theme { / Override defaults based on YOUR content needs / --breakpoint-sm: 36rem; / 576px - when your content needs more space / --breakpoint-md: 48rem; / 768px / --breakpoint-lg: 62rem; / 992px - common content width / --breakpoint-xl: 75rem; / 1200px / --breakpoint-2xl: 90rem; / 1440px /

/ Add custom breakpoints for specific content needs / --breakpoint-xs: 20rem; / 320px - very small devices / --breakpoint-3xl: 120rem; / 1920px - ultra-wide / }

Screen Coverage Strategy

Mobile base
Tablet enhancement
Desktop enhancement
Wide desktop

Fluid Typography System CSS Clamp for Smooth Scaling

Fluid typography eliminates jarring size jumps between breakpoints:

@theme { / Fluid typography scale / --text-fluid-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem); --text-fluid-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem); --text-fluid-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem); --text-fluid-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem); --text-fluid-xl: clamp(1.25rem, 1rem + 1.25vw, 1.5rem); --text-fluid-2xl: clamp(1.5rem, 1.1rem + 2vw, 2rem); --text-fluid-3xl: clamp(1.875rem, 1.2rem + 3.375vw, 2.5rem); --text-fluid-4xl: clamp(2.25rem, 1rem + 6.25vw, 3.5rem); --text-fluid-5xl: clamp(3rem, 1rem + 10vw, 5rem); }

Important for Accessibility: Always combine vw with rem to respect user zoom preferences (WCAG compliance).

Using Fluid Typography

Responsive Heading

Body text that scales proportionally with the viewport while respecting user's font size preferences.

Section Title

Fluid Spacing System Clamp-Based Spacing @theme { / Fluid spacing scale / --spacing-fluid-xs: clamp(0.25rem, 0.2rem + 0.25vw, 0.5rem); --spacing-fluid-sm: clamp(0.5rem, 0.4rem + 0.5vw, 1rem); --spacing-fluid-md: clamp(1rem, 0.75rem + 1.25vw, 2rem); --spacing-fluid-lg: clamp(1.5rem, 1rem + 2.5vw, 3rem); --spacing-fluid-xl: clamp(2rem, 1.25rem + 3.75vw, 4rem); --spacing-fluid-2xl: clamp(3rem, 1.5rem + 7.5vw, 6rem); --spacing-fluid-section: clamp(4rem, 2rem + 10vw, 8rem); }

Using Fluid Spacing

Section Title

Hero Title

Hero description

Touch-Friendly Interactive Elements WCAG 2.2 Touch Target Requirements

Minimum sizes (2025 standards):

WCAG 2.2 Level AA: 24x24 CSS pixels minimum Recommended: 44x44 CSS pixels (Apple, Google, Microsoft guidelines) Optimal: 48x48 CSS pixels for critical actions

Extended Touch Targets

Small visible link

Touch Target Spacing

Container Queries (2025 Game-Changer)

Container queries enable component-level responsiveness, independent of viewport size.

Setup @import "tailwindcss"; @plugin "@tailwindcss/container-queries";

Container Query Breakpoints Class Min-width @xs 20rem (320px) @sm 24rem (384px) @md 28rem (448px) @lg 32rem (512px) @xl 36rem (576px) @2xl 42rem (672px) @3xl 48rem (768px) @4xl 56rem (896px) @5xl 64rem (1024px) Practical Container Query Patterns

Card Title

Description that adapts to available space...

Tag

Named Containers

When to Use Container vs Viewport Queries Use Container Queries Use Viewport Queries Reusable components Page-level layouts Sidebar widgets Navigation bars Card grids Hero sections Embedded content Full-width sections CMS/dynamic content Fixed app shells Responsive Layout Patterns Mobile-First Grid System

Responsive Flexbox Patterns

Content 1
Content 2
Item 1
Item 2
Item 3

Title

Description

Responsive Sidebar Layouts

Content
Content

Holy Grail Layout (2025)

Main Content
Footer content

Responsive Images Aspect Ratio Containers

Responsive Image Sizes

Description

Responsive image

Responsive Typography Patterns Heading Hierarchy

Main Heading

Section Heading

Subsection Heading

Readable Body Text

Body text optimized for readability with 45-75 characters per line.

This heading will balance text across lines to avoid orphans

Mobile Navigation Patterns Hamburger to Full Nav

Bottom Navigation (Mobile App Style)

Content

Safe Area Handling (Notched Devices) @utility safe-area-pt { padding-top: env(safe-area-inset-top); }

@utility safe-area-pb { padding-bottom: env(safe-area-inset-bottom); }

@utility safe-area-pl { padding-left: env(safe-area-inset-left); }

@utility safe-area-pr { padding-right: env(safe-area-inset-right); }

@utility safe-area-p { padding-top: env(safe-area-inset-top); padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left); }

Navigation

Performance Optimization for Mobile Lazy Loading

...

Heavy component loaded on demand

Content Visibility @utility content-auto { content-visibility: auto; contain-intrinsic-size: auto 500px; }

Large section that may be off-screen

Reduced Data Usage

...

Responsive Testing Checklist Essential Tests 320px - Smallest supported width (older iPhones) 375px - Modern iPhone base 414px - Large phones (iPhone Plus/Max) 768px - iPad portrait 1024px - iPad landscape / small laptop 1280px - Standard laptop 1440px - Large desktop 1920px - Full HD desktop Quality Checks Text remains readable at all sizes Touch targets are minimum 44px on mobile No horizontal scroll on any viewport Images don't overflow containers Navigation is accessible on all sizes Forms are usable on mobile Modals fit mobile screens Tables have mobile alternatives Performance under 3s LCP on 3G Best Practices Summary Practice Implementation Mobile-first utilities Unprefixed first, then sm:, md:, lg: Touch targets min-h-11 min-w-11 (44px minimum) Fluid typography clamp(min, preferred, max) with rem + vw Fluid spacing clamp() for padding and margins Container queries @container for component responsiveness Safe areas env(safe-area-inset-*) for notched devices Readable text max-w-prose (65ch) and leading-relaxed Lazy loading loading="lazy" on below-fold images Touch spacing gap-3 (12px) minimum between targets Viewport meta width=device-width, initial-scale=1

返回排行榜