<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.0.0",
    "iPadOS: 13.0.0 - 27.0.0",
    "macCatalyst: 13.0.0 - 27.0.0",
    "macOS: 10.15.0 - 27.0.0",
    "tvOS: 13.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 6.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/accentColor(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE11accentColoryQrAA0E0VSgF"
  },
  "title" : "accentColor(_:)"
}
-->

# accentColor(_:)

Sets the accent color for this view and the views it contains.

```
nonisolated func accentColor(_ accentColor: Color?) -> some View
```

## Parameters

`accentColor`

The color to use as an accent color. Set the
value to `nil` to use the inherited accent color.

## Discussion

Use `accentColor(_:)` when you want to apply a broad theme color to
your app’s user interface. Some styles of controls use the accent color
as a default tint color.

> Note: In macOS, SwiftUI applies customization of the accent color
> only if the user chooses Multicolor under General > Accent color
> in System Preferences.

In the example below, the outer [`VStack`](/documentation/SwiftUI/VStack) contains two child views. The
first is a button with the default accent color. The second is a [`VStack`](/documentation/SwiftUI/VStack)
that contains a button and a slider, both of which adopt the purple
accent color of their containing view. Note that the [`Text`](/documentation/SwiftUI/Text) element
used as a label alongside the `Slider` retains its default color.

```
VStack(spacing: 20) {
    Button(action: {}) {
        Text("Regular Button")
    }
    VStack {
        Button(action: {}) {
            Text("Accented Button")
        }
        HStack {
            Text("Accented Slider")
            Slider(value: $sliderValue, in: -100...100, step: 0.1)
        }
    }
    .accentColor(.purple)
}
```

![A VStack showing two child views: one VStack containing a default accented button, and a second VStack where the VStack has a purple accent color applied. The accent color modifies the enclosed button and slider, but not the color of a Text item used as a label for the slider.](images/com.apple.SwiftUI/View-accentColor-1@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)