<!--
{
  "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/TableColumn",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11TableColumnV"
  },
  "title" : "TableColumn"
}
-->

# TableColumn

A column that displays a view for each row in a table.

```
nonisolated struct TableColumn<RowValue, Sort, Content, Label> where RowValue : Identifiable, Sort : SortComparator, Content : View, Label : View
```

## Overview

You create a column with a label, content view, and optional key path.
The table calls the content content builder with the value for each row
in the table. The column uses a key path to map to a property of each row
value, which sortable tables use to reflect the current sort order.

The following example creates a sortable column for a table with `Person`
rows, displaying each person’s given name:

```
TableColumn("Given name", value: \.givenName) { person in
    Text(person.givenName)
}
```

For the common case of `String` properties, you can use the convenience
initializer that doesn’t require an explicit content closure and displays
that string verbatim as a [`Text`](/documentation/SwiftUI/Text) view. This means you can write the
previous example as:

```
TableColumn("Given name", value: \.givenName)
```

## Topics

### Creating an unsortable column

[`init ( _ : value :)`](/documentation/SwiftUI/TableColumn/init(_:value:))

Creates an unsortable column that displays a string property that
generates its label from a localized string resource.

[`init ( _ : content :)`](/documentation/SwiftUI/TableColumn/init(_:content:))

Creates an unsortable column that generates its label from a localized
string resource.

### Creating a sortable column

[`init ( _ : value : content :)`](/documentation/SwiftUI/TableColumn/init(_:value:content:))

Creates a sortable column for Boolean values
that generates its label from a localized string resource.

[`init ( _ : value : comparator :)`](/documentation/SwiftUI/TableColumn/init(_:value:comparator:))

Creates a sortable column that displays a string property, and
generates its label from a localized string resource.

[`init ( _ : value : comparator : content :)`](/documentation/SwiftUI/TableColumn/init(_:value:comparator:content:))

Creates a sortable column that generates its label from a localized
string resource.

[`init ( _ : sortUsing : content :)`](/documentation/SwiftUI/TableColumn/init(_:sortUsing:content:))

Creates a sortable column that generates its label from a localized
string resource.

### Setting the column width

[`width(_:)`](/documentation/SwiftUI/TableColumn/width(_:))

Creates a fixed width table column that isn’t user resizable.

[`width(min:ideal:max:)`](/documentation/SwiftUI/TableColumn/width(min:ideal:max:))

Creates a resizable table column with the provided constraints.

[`width()`](/documentation/SwiftUI/TableColumn/width())

Sets the column’s width.

## Relationships

### Conforms To

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

---

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)