---
title: selection
framework: swiftui
role: symbol
role_heading: Type Property
path: swiftui/shapestyle/selection
---

# selection

A style used to visually indicate selection following platform conventional colors and behaviors.

## Declaration

```swift
static var selection: SelectionShapeStyle { get }
```

## Discussion

Discussion For example: ForEach(items) {    ItemView(value: item, isSelected: item.id == selectedID) }

struct ItemView {     var value: item     var isSelected: Bool

var body: some View {         // construct the actual cell content             .background(isSelected                 ? AnyShapeStyle(.selection)                     : AnyShapeStyle(.fill.quaternary),                 in: .rect(cornerRadius: 6))     } } On macOS and iPadOS this automatically reflects window key state and focus state, where the emphasized appearance will be used only when the window is key and the nearest focusable element is actually focused. On iPhone, this will always fill with the environment’s accent color. When applied as a background of another view, it will automatically set the EnvironmentValues.backgroundProminence for the environment of that view to match the current prominence of the selection. For information about how to use shape styles, see ShapeStyle.

## See Also

### Semantic styles

- [foreground](swiftui/shapestyle/foreground.md)
- [background](swiftui/shapestyle/background.md)
- [separator](swiftui/shapestyle/separator.md)
- [tint](swiftui/shapestyle/tint.md)
- [placeholder](swiftui/shapestyle/placeholder.md)
- [link](swiftui/shapestyle/link.md)
- [fill](swiftui/shapestyle/fill.md)
- [windowBackground](swiftui/shapestyle/windowbackground.md)
