TechnologiesSwiftUI

LinkShapeStyle struct

iOSmacOStvOSwatchOSvisionOSiOS 17.0+✓ renders

A style appropriate for links.

How it works

LinkShapeStyle is the ShapeStyle that paints content with the system's link color—the same accent the platform uses to signal tappable hyperlinks. Rather than constructing it directly, you reach for it through the static accessor .link wherever a ShapeStyle is expected, letting text, symbols, and shape fills adopt the standard link tint without hard-coding a color value. Use it when you want UI to read as a link and to stay consistent with the platform's appearance, accessibility settings, and light/dark adaptations.

  1. Reach for the style through the .link accessor

    LinkShapeStyle is exposed as a static member on ShapeStyle, so you write the leading-dot form .link instead of naming the type. Every use in the example—.foregroundStyle(.link) on the Text and Label, and .fill(.link) on the RoundedRectangle—resolves to this single shared style.

  2. Tint foreground content with foregroundStyle(.link)

    Because LinkShapeStyle conforms to ShapeStyle, it can drive the foreground of text and symbols. Text("Visit our site") and Label("Open Link", systemImage: "link") both apply .foregroundStyle(.link), so their glyphs render in the link color and the underlying values flow through unchanged.

  3. Fill shapes with the same link color

    The same style works anywhere a ShapeStyle is accepted, including a shape's fill. RoundedRectangle(cornerRadius: 8).fill(.link) paints the rectangle in the link tint, demonstrating that LinkShapeStyle is not limited to text and behaves like any other fillable style.

  4. Let it adapt instead of hard-coding a color

    LinkShapeStyle resolves against the current environment, so the link color tracks appearance and accessibility settings automatically. Choosing .link over a literal such as .blue is what keeps the Text, Label, and RoundedRectangle visually consistent and correct across light and dark contexts.

Try it — Swap .fill(.link) on the RoundedRectangle for .fill(.blue) and watch the rectangle stop tracking the system link tint, revealing what LinkShapeStyle was supplying.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

LinkShapeStyle.swift
struct LinkShapeStyleDemo: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 12) {
            Text("Visit our site")
                .font(.headline)
                .foregroundStyle(.link)
            Label("Open Link", systemImage: "link")
                .foregroundStyle(.link)
            RoundedRectangle(cornerRadius: 8)
                .fill(.link)
                .frame(height: 40)
                .overlay(Text("Tap").foregroundStyle(.white))
        }
        .padding()
    }
}
Live preview
Visit our site Open Link Tap
Visit our site Open Link Tap
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →