<!--
{
  "availability" : [
    "iOS: 27.3.0 -",
    "iPadOS: 27.3.0 -",
    "macCatalyst: -",
    "macOS: 27.3.0 -",
    "tvOS: 27.3.0 -",
    "visionOS: 27.3.0 -",
    "watchOS: 27.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/CardSnippet",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "App Intents",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:19_AppIntents_SwiftUI11CardSnippetV"
  },
  "title" : "CardSnippet"
}
-->

# CardSnippet

A type that presents the SwiftUI view for an app entity as a card.

```
struct CardSnippet<Entity, Content> where Entity : AppEntity, Content : View
```

## Overview

A `CardSnippet` type generates a card-style presentation that includes the contents of a SwiftUI view
you provide. The system delivers cards in various contexts, including Siri responses and conversation
transcripts. When your entity adopts the [`SnippetRepresentableEntity`](/documentation/AppIntents/SnippetRepresentableEntity) protocol, you create this type
and return it from your entity’s [`snippet`](/documentation/AppIntents/SnippetRepresentableEntity/snippet) property.

When you create a `CardSnippet`, you provide a view builder that returns a SwiftUI view with content from
the specified entity. The system creates a SwiftUI view archive from it to display your view in different contexts.
You specify which contexts you support at initialization time by specifying the families you support. If your snippet doesn’t support a
requested family, the system shows the content from your entity’s display representation instead of the archived view.

The following example shows the creation of a `CardSnippet` for an entity that manages a photo. The snippet
supports the standard family, which offers sufficient space to display your content on iPhone or similarly
large display. When the system runs the provided closure, it provides you with the entity to display  and a context object for adjusting the configuration of your views.

```swift
extension PhotoEntity: SnippetRepresentableEntity {
    static var snippet: some EntitySnippetContent<Self> {
        CardSnippet(supportedFamilies: [.standard]) { photo, context in
            PhotoCardView(photo: photo)
        }
    }
}
```

When you build the content for your snippet, create views with primarily static content such as text and
images. The system renders snippets in advance and stores your views in a static archive it can use at any
time, including when your app isn’t running. Because rendering happens in advance, you can’t change the
content of your view dynamically later. If your view requires data that isn’t immediately available in your
entity, prepare the data before returning the SwiftUI view from your snippet. For example, if you need
to create custom images, create them before you return your view. Prepare data
synchronously to ensure it’s available when you create your view. If you generate data asynchronously,
it likely won’t be available in time.

## Topics

### Creating a card snippet

[`init(supportedFamilies: [CardSnippetFamily], content: (Entity, CardSnippetContext) -> Content)`](/documentation/AppIntents/CardSnippet/init(supportedFamilies:content:))

Creates a card snippet with the views for specific families of content.

## Relationships

### Conforms To

[`EntitySnippetContent`](/documentation/AppIntents/EntitySnippetContent)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)