Mobile Detection
Overview
Section titled “Overview”DS one includes automatic mobile and device detection, allowing your components to adapt to different screen sizes and device capabilities.
Device Detection
Section titled “Device Detection”The system automatically detects:
- Mobile devices (phones and tablets)
- Touch-capable devices
- Screen size breakpoints
- Device orientation
Responsive Components
Section titled “Responsive Components”DS one components automatically adapt to mobile devices:
<!-- Automatically responsive --><ds-layout> <header-v1>Navigation</header-v1> <main>Content adapts to screen size</main></ds-layout>
Touch Events
Section titled “Touch Events”Components automatically handle touch events on mobile devices:
<button-v1 variant="primary"> <!-- Handles both click and touch events --> Tap Me</button-v1>
Device-Specific Styling
Section titled “Device-Specific Styling”Apply styles based on device type:
/* Mobile-specific styles */@media (max-width: 768px) { button-v1 { --button-size: larger; }}
/* Touch device styles */@media (hover: none) { button-v1 { --button-padding: 1rem; }}
JavaScript Detection
Section titled “JavaScript Detection”Access device information in JavaScript:
// Check if mobileif (window.innerWidth < 768) { console.log("Mobile device detected");}
// Check for touch supportif ("ontouchstart" in window) { console.log("Touch-capable device");}
Responsive Breakpoints
Section titled “Responsive Breakpoints”DS one uses these standard breakpoints:
- Mobile: < 768px
- Tablet: 768px - 1024px
- Desktop: > 1024px
Best Practices
Section titled “Best Practices”- Test on real devices when possible
- Use responsive units (rem, em, %)
- Design mobile-first
- Ensure touch targets are at least 44x44px
- Test both portrait and landscape orientations