<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 12.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/TableRowContent",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15TableRowContentP"
  },
  "title" : "TableRowContent"
}
-->

# TableRowContent

A type used to represent table rows.

```
@MainActor @preconcurrency protocol TableRowContent<TableRowValue>
```

## Overview

Like with the [`View`](/documentation/SwiftUI/View) protocol, you can create custom table row content
by declaring a type that conforms to the `TableRowContent` protocol and implementing
the required [`tableRowBody`](/documentation/SwiftUI/TableRowContent/tableRowBody-swift.property) property.

```
struct GroupOfPeopleRows: TableRowContent {
    @Binding var people: [Person]

    var tableRowBody: some TableRowContent<Person> {
        ForEach(people) { person in
            TableRow(person)
                .itemProvider { person.itemProvider }
        }
        .dropDestination(for: Person.self) { destination, newPeople in
            people.insert(contentsOf: newPeople, at: destination)
        }
    }
}
```

This example uses an opaque result type and specifies that the
primary associated type `TableRowValue` for the `tableRowBody`
property is a `Person`. From this, SwiftUI can infer
`TableRowValue` for the `GroupOfPeopleRows` structure is also `Person`.

A type conforming to this protocol inherits `@preconcurrency @MainActor`
isolation from the protocol if the conformance is included in the type’s
base declaration:

```
struct MyCustomType: Transition {
    // `@preconcurrency @MainActor` isolation by default
}
```

Isolation to the main actor is the default, but it’s not required. Declare
the conformance in an extension to opt out of main actor isolation:

```
extension MyCustomType: Transition {
    // `nonisolated` by default
}
```

## Topics

### Getting the row body

[`var tableRowBody: Self.TableRowBody`](/documentation/SwiftUI/TableRowContent/tableRowBody-swift.property)

The composition of content that comprise the table row content.

[`associatedtype TableRowBody : TableRowContent`](/documentation/SwiftUI/TableRowContent/TableRowBody-swift.associatedtype)

The type of content representing the body of this table row content.

### Defining the row value

[`associatedtype TableRowValue : Identifiable = Self.TableRowBody.TableRowValue`](/documentation/SwiftUI/TableRowContent/TableRowValue)

The type of value represented by this table row content.

### Managing interaction

[`func draggable<T>(@autoclosure () -> T) -> some TableRowContent<Self.TableRowValue>`](/documentation/SwiftUI/TableRowContent/draggable(_:))

Activates this row as the source of a drag and drop operation.

[`func dropDestination<T>(for: T.Type, action: ([T]) -> Void) -> some TableRowContent<Self.TableRowValue>`](/documentation/SwiftUI/TableRowContent/dropDestination(for:action:))

Defines the entire row as a destination of a drag and drop operation
that handles the dropped content with a closure that you specify.

[`func onHover(perform: (Bool) -> Void) -> some TableRowContent<Self.TableRowValue>`](/documentation/SwiftUI/TableRowContent/onHover(perform:))

Adds an action to perform when the pointer moves onto or away from the
entire row.

[`func itemProvider((() -> NSItemProvider?)?) -> ModifiedContent<Self, ItemProviderTableRowModifier>`](/documentation/SwiftUI/TableRowContent/itemProvider(_:))

Provides a closure that vends the drag representation for a
particular data element.

[`struct ItemProviderTableRowModifier`](/documentation/SwiftUI/ItemProviderTableRowModifier)

A table row modifier that associates an item provider with some base
row content.

### Adding a context menu to a row

[`func contextMenu<M>(menuItems: () -> M) -> ModifiedContent<Self, _ContextMenuTableRowModifier<M>>`](/documentation/SwiftUI/TableRowContent/contextMenu(menuItems:))

Adds a context menu to a table row.

[`func contextMenu<M, P>(menuItems: () -> M, preview: () -> P) -> ModifiedContent<Self, _ContextMenuPreviewTableRowModifier<M, P>>`](/documentation/SwiftUI/TableRowContent/contextMenu(menuItems:preview:))

Adds a context menu with a preview to a table row.

### Instance Methods

[`func selectionDisabled(Bool) -> some TableRowContent<Self.TableRowValue>`](/documentation/SwiftUI/TableRowContent/selectionDisabled(_:))

Adds a condition that controls whether users can select this row.

## Relationships

### Conforming Types

[`TableForEachContent`](/documentation/SwiftUI/TableForEachContent)

[`EmptyTableRowContent`](/documentation/SwiftUI/EmptyTableRowContent)

[`ModifiedContent`](/documentation/SwiftUI/ModifiedContent)

[`TupleTableRowContent`](/documentation/SwiftUI/TupleTableRowContent)

[`Group`](/documentation/SwiftUI/Group)

[`TableHeaderRowContent`](/documentation/SwiftUI/TableHeaderRowContent)

[`TableRow`](/documentation/SwiftUI/TableRow)

[`ForEach`](/documentation/SwiftUI/ForEach)

[`OutlineGroup`](/documentation/SwiftUI/OutlineGroup)

[`Section`](/documentation/SwiftUI/Section)

[`DisclosureTableRow`](/documentation/SwiftUI/DisclosureTableRow)

[`TableOutlineGroupContent`](/documentation/SwiftUI/TableOutlineGroupContent)

### Inherited By

[`DynamicTableRowContent`](/documentation/SwiftUI/DynamicTableRowContent)

---

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)