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.
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 theTextandLabel, and.fill(.link)on theRoundedRectangle—resolves to this single shared style.Tint foreground content with foregroundStyle(.link)
Because LinkShapeStyle conforms to ShapeStyle, it can drive the foreground of text and symbols.
Text("Visit our site")andLabel("Open Link", systemImage: "link")both apply.foregroundStyle(.link), so their glyphs render in the link color and the underlying values flow through unchanged.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.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
.linkover a literal such as.blueis what keeps theText,Label, andRoundedRectanglevisually consistent and correct across light and dark contexts.
.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.
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()
}
}