Overview
Despia provides an optimized native runtime environment using WKWebView (iOS) and Android WebView (Android), with integrated GPU acceleration, caching mechanisms, and native SDK interfaces. Your application’s structural architecture (frame composition, scroll behavior, and element interactions) is determined by your codebase implementation. This guide documents structural patterns and best practices for building production-ready applications on the Despia platform.Root Frame Structure
Foundation Architecture
Applications require a root frame element that establishes the viewport boundaries and contains all structural components.Implementation
- Use
position: fixedfor root frame (do not useheight: 100vh) - Include dedicated safe area spacer elements
- Header and footer use
flex-shrink: 0(non-scrolling) - Content area uses
flex: 1andoverflow-y: auto(scrollable) - Apply
scrollbar-width: nonefor native appearance
Device Boundaries
Safe Area Variables
The Despia runtime automatically injects CSS variables for device-specific boundary insets (notches, status bars, home indicators).PWA Fallback Implementation
When deployed as a PWA, Despia-specific variables are unavailable. Implement fallback values using standard environment variables.Viewport Configuration
Required meta tag configuration:viewport-fit=cover attribute enables safe area inset functionality. Omitting this attribute will prevent proper device boundary handling.
Spacing System
Unit Standards
All spacing values (padding, margin, gaps) must userem units to ensure consistent scaling and accessibility compliance.
0.5rem= 8px1rem= 16px1.5rem= 24px2rem= 32px2.75rem= 44px
Interactive Elements
Touch Target Requirements
Interactive elements must meet minimum size requirements for reliable touch interaction: 2.75rem × 2.75rem (44px × 44px).Scroll Containers
Container-Based Scrolling
Implement scrolling through dedicated container elements. Scrolling the body element interferes with fixed positioning, pull-to-refresh functionality, and safe area handling.Pull-to-Refresh Prevention
scrollbar-width: thin instead of none.
Form Elements
Input Sizing Standards
Apply minimum font size of 1rem to all form inputs for readability and consistency.Virtual Keyboard Adaptation
The virtual keyboard reduces the available viewport height. Applications using the fixed frame structure automatically adapt to keyboard appearance without additional configuration. Optional Keyboard Detection: For custom keyboard-aware behavior:Element Behavior
Text Selection
The Despia runtime automatically prevents text selection across your application to provide a native app experience. This prevents users from accidentally selecting UI elements during interactions. Enabling Text Selection: For specific elements that should allow text selection (paragraphs, articles, code blocks), add theselectable="true" attribute:
Touch Feedback Implementation
Provide visual feedback for touch interactions:Complete Implementation Example
Common Implementation Errors
Using height: 100vh for Root Frame
position: fixed for root frame elements.
Enabling Body Element Scrolling
Omitting Safe Area Spacer Elements
Using Pixel Units for Spacing
Undersized Interactive Elements
Incorrect Viewport Configuration
viewport-fit=cover attribute.
Missing PWA Fallback Values
Validation Checklist
Before deployment:- Root frame uses fixed positioning (not
100vh) - Safe area spacer divs included
- Body element has overflow hidden (no scrolling)
- Content containers handle scrolling
- All spacing uses rem units
- Interactive elements meet 2.75rem minimum size
- Scrollbars hidden on scroll containers
- Despia variables include PWA fallbacks
- Tested in Despia iOS runtime
- Tested in Despia Android runtime
- Tested in PWA mode (fallbacks functional)
- Verified on devices with notches
- Keyboard behavior validated
- Orientation changes handled (portrait and landscape)
API Reference
Despia Runtime Features
The following features are automatically provided by the Despia runtime:- Input zoom prevention
- Text selection prevention (native app behavior)
- Native webview optimization (WKWebView on iOS, Android WebView on Android)
- Performance optimization and caching
- Native SDK integrations
Selectable Attribute
Enable text selection on specific elements:Root Frame Pattern
Safe Area Pattern
Scroll Container Pattern
Spacing Values
| rem Value | Pixel Equivalent | Use Case |
|---|---|---|
| 0.5rem | 8px | Tight spacing |
| 1rem | 16px | Default spacing |
| 1.5rem | 24px | Medium spacing |
| 2rem | 32px | Large spacing |
Element Sizing Standards
- Interactive elements:
min-width: 2.75rem; min-height: 2.75rem(44px) - Form inputs:
font-size: 1rem; padding: 0.75rem - Interactive element spacing:
gap: 0.5remminimum