Platform Context
ThePlatform context provides access to platform-specific information and capabilities:
Platform Properties
ThePlatform struct includes:
root_size: State<Size2D>- Current window/root sizefocused_accessibility_id: State<AccessibilityId>- Currently focused elementnavigation_mode: State<NavigationMode>- Keyboard or mouse navigationpreferred_theme: State<PreferredTheme>- System theme preferencesender: Rc<dyn Fn(UserEvent)>- Send user events
Window Management
Window Configuration
Configure your window at launch:Window Properties
Size:Custom Window Attributes
For advanced window configuration using Winit:Window Size and Viewport
Reading Window Size
Access the current window size reactively:Responsive Layouts
Adjust layout based on window size:System Theme
Detecting System Theme
Read the system’s preferred theme:Reacting to Theme Changes
Automatically update when system theme changes:Navigation Mode
Detect whether the user is navigating with keyboard or mouse:Clipboard Integration
Access the system clipboard:File System Access
File Picker
Open native file picker dialogs:Drag and Drop
Handle file drag and drop:Multi-Window Support
Create and manage multiple windows:Window Events
Close Request
Handle window close events:System Tray Integration
Add your app to the system tray:Custom Window Titlebar
Create a custom titlebar with window controls:Best Practices
- Handle window lifecycle - Properly clean up resources on window close
- Responsive design - Test with different window sizes
- Theme awareness - Respect system theme preferences
- Keyboard navigation - Support keyboard-only navigation
- Accessibility - Provide proper accessibility information
- Platform-specific features - Use conditional compilation for platform-specific code:
Common Patterns
Frameless Draggable Window
Splash Screen
Next Steps
- Learn about Events for handling user interactions
- Explore State Management for window state
- Check out Accessibility for inclusive apps