Skip to content

FB23802262: Text.foregroundStyle(.secondary) has different behavour than other SwiftUI views #826

Description

@CraigSiemens

Submission Date

20216-07-16

Status

Open

Area

SwiftUI

Operating System Version

iOS 26.5

Type

Incorrect/Unexpected Behavior

Description

Steps to reproduce (example below)
Setup a container view setting a custom primary and secondary foreground style (blue and orange).
Add a Text with .foregroundStyle(.secondary)

Expected behaviour
The text should use the secondary foreground style (orange) that is set on its parent view, matching the behaviour of calling the same modifier on other views (Button, Label, etc) or containers containing text (HStack, Group, etc).

Actual Behaviour
The text uses the secondary style of the primary foreground style (faded blue).

Example

var text: some View {
    Text("Secondary")
}

#Preview {
    VStack {
        Section("Actual") {
            Text("Modified Primary").foregroundStyle(.secondary)
        }

        Divider()

        Section("Expected") {
            text.foregroundStyle(.secondary)
            HStack { Text("Secondary") }.foregroundStyle(.secondary)
            Group { Text("Secondary") }.foregroundStyle(.secondary)
            AnyView(Text("Secondary")).foregroundStyle(.secondary)
            Button("Secondary") {}.foregroundStyle(.secondary)
        }
    }
    .foregroundStyle(.blue, .orange)
}

Keywords

No response

Prerequisites

  • The title follows the format FB<number>: <title>
  • I will keep this issue updated with Apple's responses

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions