TechnologiesSwiftUI

InsetTableStyle struct

iOSmacOStvOSwatchOSvisionOS✓ renders

The table style that describes the behavior and appearance of a table with

How it works

InsetTableStyle is the table style that insets a Table's rows from its leading and trailing edges, giving the data a framed, contained appearance rather than running edge to edge. It conforms to the TableStyle protocol, so you don't construct or interact with it directly — you select it through the tableStyle(_:) modifier and let SwiftUI apply the platform's inset layout to the rows, headers, and column dividers. Reach for it when a table sits inside other content and you want its rows visually grouped and indented to read as a distinct unit.

  1. Conforms to the TableStyle protocol

    InsetTableStyle is one of the concrete types that adopt TableStyle, the protocol SwiftUI uses to describe a table's overall appearance. As a style value it carries no configuration of its own; its job is to define how a Table's rows are arranged and inset when the system lays them out.

  2. Apply it with the .inset shorthand

    Rather than naming the type, you reach InsetTableStyle through the static .inset member on TableStyle. In the example, .tableStyle(.inset) resolves to this style, which is the dot-shorthand the framework provides so you can request the inset appearance without writing the full type name.

  3. Set it through the tableStyle(_:) modifier

    The tableStyle(_:) view modifier is where the style plugs in: it takes a TableStyle value and applies it to the Table it modifies, along with any tables nested in that view's hierarchy. Here Table(people) is followed by .tableStyle(.inset), which hands InsetTableStyle to the table built from the TableColumn definitions for "Name" and "Role".

  4. Affects the Table's row and column layout

    Once applied, the style governs how the table's content is positioned — its rows are pulled in from the container's edges and presented as a grouped block. The columns declared by TableColumn("Name", value: \.name) and TableColumn("Role", value: \.role) are unchanged in content; only their inset framing within the surrounding view responds to the chosen style.

Try it — Change .tableStyle(.inset) to .tableStyle(.bordered) and watch the rows lose their inset framing and span the full width with full-grid borders instead.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

InsetTableStyle.swift
struct InsetTableStyleDemo: View {
    struct Person: Identifiable {
        let id = UUID()
        let name: String
        let role: String
    }

    private let people = [
        Person(name: "Ada Lovelace", role: "Engineer"),
        Person(name: "Alan Turing", role: "Scientist"),
        Person(name: "Grace Hopper", role: "Admiral")
    ]

    var body: some View {
        Table(people) {
            TableColumn("Name", value: \.name)
            TableColumn("Role", value: \.role)
        }
        .tableStyle(.inset)
        .padding()
    }
}
Live preview
Name Role Ada Lovelace Engineer Alan Turing Scientist Grace Hopper Admiral
Name Role Ada Lovelace Engineer Alan Turing Scientist Grace Hopper Admiral
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →