Pocket How
Design and HIG

Semantic colors and Dark Mode on iOS: system colors, contrast and tinting

iOS 17+, iPadOS 17+. Beginner. By Cihat Salik, .

Short answer

Use semantic colors such as label, secondaryLabel and systemBackground for text and surfaces, and system colors like .blue for accents. Put every custom colour in an asset catalog color set with light, dark and high contrast variants. Check text against 4.5:1 (3:1 for large or bold text) in both appearances, and keep colour on Liquid Glass for one primary action.

The problem

Colour bugs are the easiest kind to ship. A screen designed in light mode with hex values looks fine in the design file and in the simulator. Then someone opens it at night in Dark Mode and sees black text on a near-black card. Someone with Increase Contrast on sees a brand blue that barely clears the background. A widget on a tinted Home Screen turns into a white blob. And since iOS 26, a tinted button sitting on Liquid Glass can pick up the colour of whatever scrolls beneath it.

The fix is a habit more than a technique: describe colours by their role, let the system supply values per appearance, and put every custom colour in one place that has all its variants. This guide walks through the system palette, custom colours, contrast, and the places where tinting changes the rules.

Step 1: use semantic colours for text and surfaces

iOS defines dynamic colours by purpose, not by value. The HIG lists them for foreground content: label, secondaryLabel, tertiaryLabel and quaternaryLabel for text by importance, placeholderText, separator and opaqueSeparator, and link. For backgrounds there are two sets of three: systemBackground, secondarySystemBackground and tertiarySystemBackground for plain screens, and the systemGroupedBackground set for grouped lists. Primary is the screen, secondary groups content inside it, tertiary groups content inside that.

In SwiftUI you rarely name them. Hierarchical styles map to the label colours, and standard containers draw the right backgrounds.

struct OrderSummary: View {
    let title: String
    let detail: String

    var body: some View {
        VStack(alignment: .leading, spacing: 6) {
            Text(title)
                .font(.headline)
            Text(detail)
                .font(.subheadline)
                .foregroundStyle(.secondary)
        }
        .padding()
        .frame(maxWidth: .infinity, alignment: .leading)
        .background(Color(uiColor: .secondarySystemBackground), in: .rect(cornerRadius: 16))
    }
}

.foregroundStyle(.secondary) (iOS 15) follows the secondary label colour in every appearance. Color(uiColor:) (iOS 15) bridges any UIColor, including the semantic ones.

The HIG adds one rule that matters more than it looks: don’t redefine what a semantic colour means. Using separator as a text colour or secondaryLabel as a background works today and breaks the next time Apple tunes the palette.

Base and elevated backgrounds. In Dark Mode, iOS uses dimmer base backgrounds and brighter elevated ones, and switches to elevated automatically for sheets, popovers and multitasking. A custom background colour loses that, which is why the HIG asks you to prefer system backgrounds. If you must use a custom one, give it an elevated variant in the asset catalog.

Step 2: use system colours for accents, never their values

The system colours, .red, .orange, .yellow, .green, .mint, .teal, .cyan, .blue, .indigo, .purple, .pink, .brown and .gray, each have four variants: light, dark, increased contrast light, increased contrast dark. The HIG publishes the RGB values for reference and then tells you not to hard-code them, because they change between releases. They did change with iOS 26: the HIG’s colour page records updated system colour values in June 2025. An app that copied the old hex values now looks subtly off next to system apps.

Look at what Increase Contrast does to them in the HIG’s table. System yellow in light mode is RGB 255, 204, 0 by default and 161, 106, 0 with increased contrast, which is a darker gold rather than a slightly darker yellow. That jump is the point. The variant is supposed to provide clearly more differentiation.

Step 3: put custom colours in color sets

Brand colours belong in an asset catalog color set. In the Attributes inspector, set Appearances to Any, Dark and turn on High Contrast. That gives you four slots: light, dark, light high contrast, dark high contrast. The HIG’s rule is to fill all four. It adds that even an app that ships in only one appearance should provide both light and dark values, because Liquid Glass adapts between light and dark over the content beneath it.

Xcode 15 and later generate symbols for color sets, so you use them without strings. Color(.brandAccent) takes a ColorResource (iOS 17), and a typo becomes a build error instead of a silent clear colour.

Text("Upgrade")
    .foregroundStyle(Color(.brandAccent))

The Create with Swift team’s Increase Contrast guide points out a convenient exception: the AccentColor set already responds to Increase Contrast without a high-contrast slot, but every other set you define needs one. They also note the direction of the change. High-contrast variants get darker in light mode and lighter in dark mode.

When a colour must be built in code, a dynamic provider covers all four cases:

import SwiftUI
import UIKit

extension Color {
    static let chartLine = Color(uiColor: UIColor { traits in
        switch (traits.userInterfaceStyle, traits.accessibilityContrast) {
        case (.dark, .high): UIColor(red: 0.62, green: 0.84, blue: 1.00, alpha: 1)
        case (.dark, _): UIColor(red: 0.38, green: 0.70, blue: 1.00, alpha: 1)
        case (_, .high): UIColor(red: 0.00, green: 0.28, blue: 0.70, alpha: 1)
        default: UIColor(red: 0.00, green: 0.40, blue: 0.88, alpha: 1)
        }
    })
}

Prefer the asset catalog where you can. It is easier to review, and designers can edit it without touching code.

Step 4: support Dark Mode properly

The HIG’s Dark Mode page is short and opinionated.

  • Don’t add an in-app appearance switch. People expect apps to follow the system setting, and a separate toggle makes them adjust two settings. Apps that mainly show media can reasonably stay dark all the time, as Stocks does.
  • Dark isn’t an inversion. The palette uses dimmer backgrounds and brighter foregrounds, and some colours change while others don’t.
  • Images need their own care. An illustration with dark details can vanish on a dark background. Provide a dark variant in the asset catalog, or adjust it until it reads in both. A content image with a white background can glow in Dark Mode, so the HIG suggests darkening it slightly.
  • Icons may need an outline. A black droplet icon on a dark background needs a thin light edge to stay visible. SF Symbols tinted with dynamic colours handle this for you.

Antoine van der Lee’s Dark Mode guide adds the UIKit trap that still bites mixed apps. Dynamic colours resolve at the moment you read them, so a CGColor assigned to a layer’s borderColor or shadowColor doesn’t update when the appearance changes. His fix uses traitCollectionDidChange(_:), which iOS 17 replaced with registerForTraitChanges(_:handler:). The idea is the same: observe UITraitUserInterfaceStyle and reassign the layer colour.

He also prefers template images tinted with the tint colour over separate light and dark icon assets, which this article recommends too. One asset, one source of truth, and it follows Increase Contrast for free.

Step 5: check contrast with numbers

The HIG’s accessibility page uses WCAG Level AA as its guide, and Accessibility Inspector checks against it:

Text Minimum contrast ratio
Up to 17 pt, any weight 4.5:1
18 pt and larger 3:1
Bold, any size 3:1

The Dark Mode page goes further for custom colour pairs: no lower than 4.5:1, and aim for 7:1 for small text. WCAG’s enhanced level, AAA, uses the same 7:1 figure. For non-text elements such as icons and control borders, WCAG 2.2 asks for 3:1. If your default palette can’t meet these, the HIG’s fallback is to meet them at least when Increase Contrast is on.

The ratio itself is simple to compute. WCAG defines relative luminance by linearizing each sRGB channel (divide by 12.92 at or below 0.04045, otherwise apply the 2.4 power curve) and weighting them 0.2126, 0.7152 and 0.0722. The contrast ratio is the lighter luminance plus 0.05, divided by the darker plus 0.05. A debug helper:

struct RGB {
    var red: Double
    var green: Double
    var blue: Double

    var relativeLuminance: Double {
        func linear(_ c: Double) -> Double {
            c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4)
        }
        return 0.2126 * linear(red) + 0.7152 * linear(green) + 0.0722 * linear(blue)
    }

    func contrastRatio(with other: RGB) -> Double {
        let a = relativeLuminance
        let b = other.relativeLuminance
        return (max(a, b) + 0.05) / (min(a, b) + 0.05)
    }
}

pow comes from Foundation. Channels are 0 to 1. Run it over every text and background pair in your design tokens, in all four variants, and fail the build script if any pair drops below its threshold. Accessibility Inspector’s audit does the same on a running screen.

Contrast alone isn’t enough. The HIG’s inclusive colour section asks you never to rely on colour alone for status, interactivity or meaning. Red and green dots look the same to many colour-blind people. Pair colour with a shape, a symbol or a label. Meaning also varies by culture: Stocks shows a rising line in green for English and in red for Chinese.

Step 6: colour on Liquid Glass and tinted surfaces

Liquid Glass. Glass has no colour of its own and picks up what’s behind it. The HIG’s guidance since iOS 26 is to apply colour sparingly: tint the background of one primary action, such as Done, and leave the rest monochrome. A toolbar where every button has a blue glass background is the HIG’s own wrong example. On colourful content, prefer monochrome bars or an accent with enough difference from the content. And make sure the resting state of a screen, the top of the scroll view, is legible, even if colourful content passes under the bars later.

In code, prominent styles take care of this. .buttonStyle(.glassProminent) (iOS 26) tints with the accent colour. For custom glass, Glass.regular.tint(_:) (iOS 26) adds a tint, which should be rare.

Widgets on tinted and clear Home Screens. When people pick a tinted or clear Home Screen, WidgetKit renders widgets in the accented rendering mode. Apple’s widget article lists what happens: primary and accented content turn white on iOS, opaque images become solid white, and the background is replaced with glass or a tint. Read widgetRenderingMode from the environment, mark the parts that should pick up the accent with widgetAccentable(_:), and choose widgetAccentedRenderingMode(_:) for images. Apple suggests reserving fullColor for media such as album art and book covers.

App icons. Tinted and clear icons work the same way at the icon level, with a separate mono annotation in Icon Composer. That is covered in its own guide.

Traps and edge cases

Hard-coded white and black. Color.white text on a brand colour looks fine until the brand colour’s dark variant is lighter. Use a colour set for “text on brand” too.

Opacity tricks. Color.black.opacity(0.6) for secondary text is invisible in Dark Mode. Use .secondary.

Reduce Transparency. The HIG asks you to test Dark Mode with Increase Contrast and Reduce Transparency, separately and together. Dark text on dark material is a common failure there.

Lighting and displays. Colours look darker and more muted in sunlight and brighter in the dark. True Tone shifts the white point. Check key screens on a real device outside, not only on a calibrated monitor.

Wide colour. P3 colours usually look fine on sRGB displays, but two close P3 colours can merge and P3 gradients can clip. Asset catalogs can hold separate sRGB and P3 values if that happens.

Reading contrast at runtime. @Environment(\.colorSchemeContrast) (iOS 13) tells you whether Increase Contrast is on, for drawing code that can’t use color sets. It is read-only. Apple’s documentation recommends doing colour variants in the asset catalog when that’s all you need.

Checklist

Check Done when
Text colours Only .primary, .secondary and semantic label colours
Backgrounds System or grouped backgrounds; custom ones have elevated variants
Accents System colours by name, no copied RGB values
Custom colours Color sets with light, dark and both high contrast slots
Contrast 4.5:1 for body text, 3:1 for large or bold text and icons, in all four variants
Not colour alone Every status has a shape, symbol or label as well
Liquid Glass One tinted primary action per bar at most
Widgets Correct in accented mode with accentable groups
Layers UIKit CGColor values refresh on appearance change
Real device Checked in sunlight, in the dark, with Increase Contrast and Reduce Transparency

The four-variant contrast check is the one most teams skip. Automate it once against your colour tokens and it keeps paying off every time someone adds a new shade.

Sources and further reading

Read next