<!--
{
  "availability" : [
    "macOS: 14.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/alternatingRowBackgrounds(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE25alternatingRowBackgroundsyQrAA011AlternatingE18BackgroundBehaviorVF"
  },
  "title" : "alternatingRowBackgrounds(_:)"
}
-->

# alternatingRowBackgrounds(_:)

Overrides whether lists and tables in this view have alternating row
backgrounds.

```
nonisolated func alternatingRowBackgrounds(_ behavior: AlternatingRowBackgroundBehavior = .enabled) -> some View
```

## Parameters

`behavior`

Whether alternating row backgrounds are enabled
or not.

## Discussion

This can be used in conjunction with an explicit list or table style
or used by itself to customize the row backgrounds of the automatic
style. The only list style this has no effect on is `.sidebar.`

```
List(recipe.ingredients) {
    Text($0.name)
}
.listStyle(.bordered)
.alternatingRowBackgrounds()
```

This is able to be combined with `scrollContentBackground(_:)` and
applies an alternating row background on top of the overall
list or table background.

This can also be combined with `listRowBackground`, which overrides
the background for a specific list row, replacing the automatic
alternating background for that row.

---

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)