Skip to content

Content and Articles

Daniel S edited this page Sep 21, 2026 · 1 revision

Content and Articles

Small pieces for feeds, news and documentation lists: DFAuthorView, DFRelativeTimeTag, DFInlineTagView, DFMetadataRow and DFArticleRow. Source: Sources/DesignFoundation/Supplementary/Article/. None of them has a style protocol; they read the theme directly.

import DesignFoundation

DFAuthorView

An avatar (32 pt) with a name and optional subtitle.

DFAuthorView(initials: String, name: String, subtitle: String? = nil)
DFAuthorView(image: Image, name: String, subtitle: String? = nil)

The avatar is a DFAvatar, so it follows the active dfAvatarStyle (Avatars). The name uses typography.label, the subtitle typography.caption in textSecondary.

DFRelativeTimeTag

DFRelativeTimeTag(date: Date, referenceDate: Date = .now)

Formats with RelativeDateTimeFormatter (unitsStyle = .abbreviated) relative to referenceDate, in caption / textSecondary. formattedText is a public property. Pass a fixed referenceDate for deterministic previews and tests.

DFInlineTagView

DFInlineTagView(_ text: String)

A decorative capsule in colors.accent (15% fill), caption font. It has no selection or dismiss behavior — use DFChip (Chips-Ratings-and-Prices) for that.

DFMetadataRow

DFMetadataItem(id: String = UUID().uuidString, systemImage: String, label: String)
DFMetadataRow(items: [DFMetadataItem])

A horizontal row of small icon + text labels (caption, textSecondary, spacing.sm apart), combined into one accessibility element.

DFArticleRow

DFArticleRow(title: String, authorName: String, authorInitials: String, date: Date, tags: [String] = [])
DFArticleRow(title: String, authorName: String, authorImage: Image, date: Date, tags: [String] = [])

Composes a headline title (2 lines by default), a DFAuthorView next to a DFRelativeTimeTag, and a row of DFInlineTagViews when tags is non-empty. Tokens — DFArticleRowTokens: titleLines: Int? (default 2).

import SwiftUI
import DesignFoundation

struct Feed: View {
    let published = Date(timeIntervalSinceNow: -3 * 3600)

    var body: some View {
        VStack(alignment: .leading, spacing: 16) {
            DFAuthorView(initials: "JL", name: "Jordan Lee", subtitle: "Staff Writer")

            HStack {
                DFRelativeTimeTag(date: published)
                DFInlineTagView("Design")
            }

            DFMetadataRow(items: [
                DFMetadataItem(systemImage: "clock", label: "5 min read"),
                DFMetadataItem(systemImage: "eye", label: "1.2k views"),
            ])

            DFArticleRow(
                title: "SwiftUI in 2026: What Changed",
                authorName: "Jordan Lee",
                authorInitials: "JL",
                date: published,
                tags: ["Swift", "iOS 26"]
            )
        }
        .padding()
    }
}

Override the title line limit:

import SwiftUI
import DesignFoundation

struct ThreeLineTitles: View {
    var body: some View {
        var theme = DFTheme.slateLight
        theme.components.articleRow = DFArticleRowTokens(titleLines: 3)
        return DFArticleRow(title: "A long headline", authorName: "Jordan Lee", authorInitials: "JL", date: .now)
            .dfTheme(theme)
    }
}

Related Pages

Clone this wiki locally