A Figma component preview for your SwiftUI views

Overview

FigmaPreviewSwiftUI

A Figma component preview for your SwiftUI views. You can use Figma components instead of real views within your app until you implement them.

The Purpose

To speed up prototype development and test design choices before full-featured implementation.

Project is heavily inspired by flutter_figma_preview and jetpack-compose-figma-preview.

Requirements

FigmaPreviewSwiftUI uses SwiftUI features of macOS 11, iOS 14, tvOS 14, watchOS 7.

Setup

Add FigmaPreviewSwiftUI to your project via Swift Package Manager.

Create personal access token in account settings.

figma-access-token

Then pass this Figma access token via Environment.

") } } } ">
struct FigmaPreviewApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(\.figmaAccessToken, "")
        }
    }
}

Usage

If you're using single Figma file for all designs, you can also pass it via Environment, so you won't need to specify it for each individual component (file id could be taken from Figma share link – typically, it goes after /file/).

") .environment(\.figmaFileId, "") } } } ">
struct FigmaPreviewApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(\.figmaAccessToken, "")
                .environment(\.figmaFileId, "")
        }
    }
}

When you need to insert your Figma component, you can use two ways. Either you can specify component ID and optionally file ID directly.

", componentId: "") } } ">
struct ContentView: View {
    var body: some View {
        FigmaView(fileId: "", componentId: "")
    }
}

Alternatively, you can simply pass share link for the component.

/Name?node-id=<123123%3A3232131>") } } ">
struct ContentView: View {
    var body: some View {
        FigmaView(link: "https://www.figma.com/file/<12123123>/Name?node-id=<123123%3A3232131>")
    }
}

FigmaView will maintain its aspectRatio, but you'll need to control its frame when needed.

Component list to get component IDs

When you need to get component IDs for the elements, you can use FigmaComponentsList view (it comes with NavigationView, so you could put somewhere in developer menu of your app on early stages, or use separate app to browse components). Please note that only published components will be listed (this requires paid Figma subscription to publish these). Alternatively, you could still use share links of components from Figma. You can use share link, or file id to set up FigmaComponentsList view. Or, FigmaComponentsList could use file id passed via Environment.

struct ContentView: View {
    var body: some View {
        FigmaComponentsList()
    }
}

Reuse and contribution

You could use FigmaPreviewSwiftUI in any way you want. If you would like to contribute to the projects – contact me. Any ideas, suggestions, pull requests are welcome.

Anyway, ping me at @edeniska. :)

See also

If you use Zeplin for designs – check zeplin-preview-swiftui.

Roadmap

At the moment, there are couple of ideas of features to be added:

  • ability to overlay view with Figma representation to check the pixel-perfect differences
  • add UIKit version

License

FigmaPreviewSwiftUI is available under the MIT license. See the LICENSE file for more info.

You might also like...
Animated shine effect for your views
Animated shine effect for your views

Shine-View-SwiftUI Animated shine effect for your views @State var animateTrigger = false var body: some View { Button(action: { animate

A realistic reflective shimmer to SwiftUI Views that uses device orientation. Position any View relative to device orientation to appear as if through a window or reflected by the screen.
A realistic reflective shimmer to SwiftUI Views that uses device orientation. Position any View relative to device orientation to appear as if through a window or reflected by the screen.

A 3d rotation effect that uses Core Motion to allow SwiftUI views to appear projected in a specific direction and distance relative to the device in r

A collection of Swift functions, extensions, and SwiftUI and UIKit Views.

J's Helper A collection of Swift functions, extensions, and SwiftUI and UIKit Views. Legend: 🔸 UIKit 🔹 SwiftUI 🔺 Shared Installation In XCode 12 go

A swift package(SPM) with iOS UI component that loads and displays images from remote urls or local assets and displays in a slide-show form with auto scroll feature.

MDBannersView A swift package with an iOS UI component that loads and displays images from remote urls, local assets and displays in a slide-show form

Visualize your dividend growth. DivRise tracks dividend prices of your stocks, gives you in-depth information about dividend paying stocks like the next dividend date and allows you to log your monthly dividend income.
Visualize your dividend growth. DivRise tracks dividend prices of your stocks, gives you in-depth information about dividend paying stocks like the next dividend date and allows you to log your monthly dividend income.

DivRise DivRise is an iOS app written in Pure SwiftUI that tracks dividend prices of your stocks, gives you in-depth information about dividend paying

SwiftUI Backports - Introducing a collection of SwiftUI backports to make your iOS development easier

SwiftUI Backports Introducing a collection of SwiftUI backports to make your iOS development easier. Many backports support iOS 13+ but where UIKIt fe

Pegase is a beautifully easy tool to keep track of your financial life on all your macOS
Pegase is a beautifully easy tool to keep track of your financial life on all your macOS

Pegase 🎉 Features 📒 Documentation Personal account software Pegase is a beautifully easy tool to keep track of your financial life on all your macOS

iCloud Drive is Apple's essential connection between all your devices, Mac, iPhone, iPad, even your Windows PC.
iCloud Drive is Apple's essential connection between all your devices, Mac, iPhone, iPad, even your Windows PC.

iCloud Drive is Apple's essential connection between all your devices, Mac, iPhone, iPad, even your Windows PC.While the cost of storage seems expensive in comparison to other online storage services, its advantage is that it works natively across all your devices.

iOS Trakt Client - Keep track of your favorite TV shows and movies on your iPhone. (Under development)

CouchTracker Keep track of your favorite movies and tv shows on your iPhone Setup for development You will need Xcode 11.2.1 Swift 5.1.2 Run the follo

Owner
Danis Tazetdinov
Danis Tazetdinov
PreviewDevice - library with elegant syntax for Preview Device in SwiftUI

PreviewDevice Requirements Xcode 13.x iOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+ Usage Example: import PreviewDevice struc

Anton Paliakov 32 Nov 22, 2022
Preview with Link's meta information.(SwiftUI)

LinkPreview(SwiftUI) Preview with Link's meta information. Image Gif Get Started import SwiftUI import LinkPreview struct LinkPreview_Test: View {

null 15 Dec 16, 2022
Preview with Link's meta information with SwiftUI

LinkPreview(SwiftUI) Preview with Link's meta information. Image Gif Get Started import SwiftUI import LinkPreview struct LinkPreview_Test: View {

null 15 Dec 16, 2022
QuickLook Preview for SwiftUI on Mac Catalyst

QuickLook Preview for SwiftUI on Mac Catalyst According to the documentation for

Tom Dai 9 Dec 31, 2022
Window preview app for MacOS (on the dock) using AltTab.

DockAltTab The #1 Window manager/Task switcher & Companion for AltTab v1.1 download link https://github.com/steventheworker/DockAltTab/releases/downlo

Steven G. 40 Jan 2, 2023
Simple SwiftUI ViewModifier to easily align your views!

Align Align gives you an easy way to align views in SwiftUI. Simply import Align in whichever SwiftUI view you like and you're good to go. Align suppl

Jacob's Apps 26 Mar 15, 2022
Joseph Heck 21 Dec 14, 2022
SwiftUI component for QuickLook

GXQuickLookView SwiftUI + QuickLook. ?? Требования ✅ Xcode 12.0 ✅ Swift 5+ ✅ iOS

GARPIX iOS team 12 Sep 19, 2022
A SwiftUI component which handles logging in with Apple to Firebase

Login with Apple Firebase SwiftUI I made this SwiftUI component to handle logging in with Apple to Firebase. Demo Gif Usage in SwiftUI struct ContentV

Joe Hinkle 153 Dec 23, 2022
BottomBar component for SwiftUI

BottomBar-SwiftUI BottomBar component for SwiftUI inspired by this concept Requirements Xcode 11 iOS 13 Installation In Xcode go to File -> Swift Pack

Bezhan 455 Dec 10, 2022