Card

@MainActor
public struct Card<Content> : View where Content : View

A flexible, reusable card component that adapts to the current theme.

The Card view provides a styled container with rounded corners, background color, shadow elevation, and optional padding. It is ideal for grouping related content in a visually distinct block.

Example usage:

Card {
  Text("Profile details")
}

The card uses the current Theme from the environment to style its appearance.

  • Creates a new themed Card container.

    Declaration

    Swift

    @MainActor
    public init(
      elevation: ShadowToken = .sm,
      padding: EdgeInsets? = nil,
      backgroundColor: Color? = nil,
      @ViewBuilder content: @escaping () -> Content
    )

    Parameters

    elevation

    The shadow elevation applied to the card. Defaults to .md.

    padding

    Optional custom padding for the card’s content. If nil, uses default theme spacing.

    backgroundColor

    Optional override for the card’s background color. Defaults to theme.colors.surfaceContainerHigh.

    content

    A view builder closure containing the card’s inner content.

  • The visual representation of the card, composed of the content and its styling.

    The body applies the current theme’s spacing, shape, and shadow, and clips the view using a medium corner radius defined by the theme.

    Declaration

    Swift

    @MainActor
    public var body: some View { get }