Swiftpack.co - MartinW/TinyShinyPreviews as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by MartinW.
MartinW/TinyShinyPreviews 0.5.0
SwiftUI Preview helpers
⭐️ 0
🕓 44 weeks ago
.package(url: "https://github.com/MartinW/TinyShinyPreviews.git", from: "0.5.0")


SwiftUI Preview helpers for checking adaptability. Element previews for light and dark mode, localizations and dynamic type sizes. Device previews for iPhone 11 class devices and iPhone 12 class devices.


TinyShinyPreviews is available via Swift Package Manager.

From Xcode, go to File -> Swift Packages -> Add Package Dependency and enter https://github.com/MartinW/TinyShinyPreviews


import TinyShinyPreviews

Preview Element


Helpers for preview of SwiftUI views. Allows previews of an individual component in different states for color scheme, localisations and dynamic type settings.


import SwiftUI
import TinyShinyPreviews

struct HelloWorld: View {
  var body: some View {
    Text("Hello, World!")

struct HelloWorld_Previews: PreviewProvider {
  static var previews: some View {

Specific element previews:

  • previewSupportedLocales()
  • previewDarkTheme()
  • previewRightToLeft()
  • previewContentSize(sizeCategory: ContentSizeCategory)

Preview Device


Helpers for preview of SwiftUI screens. Allows previews of an app screen with device bezel in multiple device sizes.

For iPhone 12 size classes, the devices are iPhone 12 mini, iPhone 12, iPhone 12 Pro Max.

For iPhone 11 size classes, the devices are:

Label Devices
iPhone SE (2nd generation) iPhone 7/8/SE 2
iPhone 11 Pro iPhone X/XS/11 Pro
iPhone 11 Pro Max iPhone 11 Pro Max / XS Max / 7 Plus / 8 Plus

Default device names are used. Device names need to match the names in Xcode in Devices and Simulators.


For device preview: ContentView().previewDevice(device: .iPhone11Pro)

Can be repeated: ContentView().previewDevice(device: .iPhone12Mini) ContentView().previewDevice(device: .iPhone11Pro)

For size classes: ContentView().previewiPhone12Sizes()

import SwiftUI
import TinyShinyPreviews

struct ContentView: View {
  var body: some View {
    HStack {

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    ContentView().previewDevice(device: .iPhone11Pro)

Be sure to use .previewDevice(device: ) (for TinyShinyPreviews) not .previewDevice(value: ) (for SwiftUI)

Preview Size Classes


Helpers for preview of size classes. Allows previews of layout in multiple size class configurations.

Additional size classes are configured as: .iPhonePortrait, .iPhoneLandscape, .iPhoneLarge

Size Class Config Horizontal Vertical
.iPhonePortrait compact regular
.iPhoneLandscape compact compact
.iPhoneLarge regular compact


For specific size classes: ContentView().previewSizeClass(horizontal: .compact, vertical: .compact)

Using size class configurations: ContentView().previewSizeClass(sizeClass: .iPhoneLandscape)

For all suggested size class configurations: ContentView().previewAllSizeClasses()


This project is licensed under the MIT License - see the LICENSE.md file for details



Stars: 0
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics