title: Device-specific Layout with SwiftUI on Apple Watch and iPhone
body: <p>Sometimes, I need to make device-specific adjustments to layouts. For example, I may need to reduce spacing on an iPhone with a smaller screen or increase spacing on the largest screens. With UIKit (and even Interface Builder) it was easy to make layout exceptions for specific size classes. <strong>What is the best way to do conditional device-specific layouts with SwiftUI?</strong></p>
  
  <p>I've been scouring the SwiftUI documentation, and haven't found a way to access and use this type of information in layouts.</p>
  
  <p>Below is an example for an Apple Watch app. Per Apple's design guidelines, I'm adding 8.5 points of padding to the left and right on the 40mm Series 4. However, the 44mm should have 9.5 points of padding, and any Apple Watch older than Series 4 should have no padding.</p>
  
  <p>What is the best way to achieve this with SwiftUI?</p>
  
  <pre><code>struct ContentView : View {
  
      var body: some View {
          HStack {
              Text("Hello World")
          }.padding([.horizontal], 8.5)
      }
  }
  </code></pre>