---
title: SharePreview
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/sharepreview
---

# SharePreview

A representation of a type to display in a share preview.

## Declaration

```swift
struct SharePreview<Image, Icon> where Image : Transferable, Icon : Transferable
```

## Mentioned in

Configure your apps navigation titles

## Overview

Overview Use this type when sharing content that the system can’t preview automatically: struct Photo: Transferable {     static var transferRepresentation: some TransferRepresentation {         ProxyRepresentation(\.image)     }

public var image: Image     public var caption: String }

struct PhotoView: View {     let photo: Photo

var body: View {         photo.image             .toolbar {                 ShareLink(                     item: photo,                     preview: SharePreview(                         photo.caption,                         image: photo.image))             }     } } You can also provide a preview to speed up the sharing process. In the following example the preview appears immediately; if you omit the preview instead, the system fetches the link’s metadata over the network: ShareLink(     item: URL(string: "https://developer.apple.com/xcode/swiftui/")!,     preview: SharePreview(         "SwiftUI",         image: Image("SwiftUI")) You can provide unique previews for each item in a collection of items that a ShareLink links to: ShareLink(items: photos) { photo in     SharePreview(photo.caption, image: photo.image) } The share interface decides how to combine those previews. Each preview specifies text and images that describe an item of the type. The preview’s image parameter is typically a full-size representation of the item. For instance, if the system prepares a preview for a link to a webpage, the image might be the hero image on that webpage. The preview’s icon parameter is typically a thumbnail-sized representation of the source of the item. For instance, if the system prepares a preview for a link to a webpage, the icon might be an image that represents the website overall. The system may reuse a single preview representation for multiple previews, and show different images in each context. For more information and recommended sizes for each image, see TN2444: Best Practices for Link Previews in Messages.

## Topics

### Creating a preview

- [init(_:)](swiftui/sharepreview/init(_:).md)
- [init(_:image:)](swiftui/sharepreview/init(_:image:).md)
- [init(_:icon:)](swiftui/sharepreview/init(_:icon:).md)
- [init(_:image:icon:)](swiftui/sharepreview/init(_:image:icon:).md)

## See Also

### Linking to other content

- [Link](swiftui/link.md)
- [ShareLink](swiftui/sharelink.md)
- [TextFieldLink](swiftui/textfieldlink.md)
- [HelpLink](swiftui/helplink.md)
