Orientation

The orientation property controls the default screen orientation when your PWA is launched. This ensures your application displays optimally based on its content and intended user experience.

Purpose

Screen orientation affects:

  • User interface layout: How content is arranged on screen

  • User experience: Natural interaction patterns for your app type

  • Media consumption: Optimal viewing for videos, games, or documents

  • Device ergonomics: How users hold and interact with their device

Configuration

/config/packages/pwa.yaml
pwa:
    manifest:
        enabled: true
        orientation: "portrait"  # or landscape, any, etc.
circle-info

If not specified, the orientation defaults to any, allowing the device to rotate freely.

Available Orientations

any (Default)

Allows the application to rotate freely based on device orientation.

Best for:

  • Multi-purpose applications

  • Apps with responsive layouts

  • Content that works well in both orientations

  • Most general-purpose apps

Examples: Social media apps, news readers, general productivity tools

portrait

Locks to portrait orientation (vertical), allowing both normal and inverted portrait.

Best for:

  • Reading-focused applications

  • Social media feeds

  • Chat applications

  • Form-heavy applications

  • One-handed mobile use

Examples:

  • Instagram-like photo sharing

  • Messaging apps

  • News articles

  • Shopping apps with vertical scrolling

portrait-primary

Locks to the device's primary portrait orientation (typically upright, not inverted).

Best for:

  • Applications requiring consistent UI position

  • Apps using device sensors

  • Camera-based applications

  • Applications with fixed control positions

Examples:

  • Camera apps

  • QR code scanners

  • Fitness tracking apps

  • Applications with bottom navigation

landscape

Locks to landscape orientation (horizontal), allowing both left and right landscape.

Best for:

  • Video playback applications

  • Games

  • Presentation tools

  • Media consumption

  • Spreadsheets or wide data views

Examples:

  • Video streaming apps

  • Gaming platforms

  • Dashboard applications

  • Photo galleries

landscape-primary

Locks to the device's primary landscape orientation.

Best for:

  • Games with specific control layouts

  • Applications using device sensors in landscape

  • Car dashboard apps

  • Presentation apps

Examples:

  • Racing games

  • Flight simulators

  • Car navigation apps

  • DJ/Music production apps

Use Cases by Application Type

Social Media App

Rationale: Content feeds are designed for vertical scrolling, and users typically hold phones in portrait mode.

Video Streaming App

Rationale: Browse in portrait, watch videos in landscape. Flexibility is key.

Gaming App

Rationale: Game controls are designed for landscape, and consistency is crucial.

E-book Reader

Rationale: Reading text is more comfortable in portrait mode, mimicking physical books.

Dashboard App

Rationale: Charts and data visualizations benefit from wider screens.

Fitness Tracker

Rationale: Users often interact while exercising, requiring one-handed portrait mode.

Complete Examples

Portrait-Only Application

Landscape-Only Application

Flexible Orientation Application

Platform Behavior

iOS (iPhone/iPad)

  • Respects orientation lock if device rotation is disabled in settings

  • portrait-primary and landscape-primary may behave differently based on device

  • iPad may ignore orientation locks in some contexts

  • Supports all standard orientations

Android

  • Strongly respects manifest orientation

  • Users can override with device settings

  • Different behavior in tablet vs phone mode

  • Chrome and other browsers may handle differently

Desktop/Laptop

  • Orientation setting is typically ignored

  • Windows treated as landscape by default

  • Application runs in window mode

  • Resizing window doesn't trigger orientation changes

Best Practices

1. Choose Based on Content

Match orientation to your primary use case:

2. Consider User Context

Think about how users will hold their device:

  • One-handed use: portrait or portrait-primary

  • Two-handed comfortable viewing: landscape

  • Variable situations: any

3. Test on Real Devices

Different devices handle orientation differently:

4. Provide Responsive Design Regardless

Even with orientation lock, design responsively:

5. Don't Lock Unnecessarily

Only lock orientation when truly needed:

Advanced: Handling Orientation Changes

Even with a locked orientation in the manifest, handle rotation in your JavaScript:

Accessibility Considerations

1. Don't Restrict User Choice

Some users have accessibility needs requiring specific orientations:

  • Motor disabilities: May need landscape for larger touch targets

  • Visual impairments: May prefer portrait for easier reading

  • Physical limitations: May only be able to hold device one way

Recommendation: Use any unless orientation lock is essential.

2. Provide Clear Feedback

If your app requires a specific orientation, inform users:

3. Test with Screen Readers

Ensure orientation changes don't disrupt screen reader navigation:

Common Mistakes

1. Locking When Not Needed

Impact: Frustrates users who want to use landscape mode.

2. Wrong Orientation for Content

Impact: Poor user experience for primary use case.

3. Not Testing Both Orientations

Even with a locked orientation, test your layout in both:

  • Users may override in settings

  • Tablets behave differently

  • Desktop windows can be any size

4. Ignoring CSS Media Queries

Manifest orientation doesn't replace responsive CSS:

Debugging Orientation

1. Check Manifest in DevTools

2. Test Orientation Lock

3. Simulate on Desktop

Chrome DevTools device emulation:

Summary

Orientation best practices:

  • ✓ Use any unless you have a specific reason to lock

  • ✓ Match orientation to your primary use case (video → landscape, reading → portrait)

  • ✓ Test on real devices in both orientations

  • ✓ Provide responsive CSS regardless of manifest setting

  • ✓ Consider accessibility needs before locking orientation

  • ✓ Inform users if a specific orientation is required

  • ✗ Don't lock orientation unnecessarily

  • ✗ Don't forget to test orientation changes even when locked

Last updated

Was this helpful?