Text Wrapping
Enable multi-line text cells when content exceeds column width.
Enabling Text Wrapping
var config = DataTableConfiguration()
config.textLayout = .wrap
config.rowHeightMode = .automatic(estimated: 60)
let dataTable = SwiftDataTable(data: items, columns: columns, options: config)Text Layout Options
Single Line (Default)
config.textLayout = .singleLine(truncation: .byTruncatingTail)Long text is truncated: "This is a very long te..."
Wrapped
config.textLayout = .wrapLong text flows to multiple lines.
Text wrapping requires automatic row heights. If you use .fixed height, wrapped text will be clipped.
Example: Notes Table
struct Note: Identifiable {
let id: Int
let title: String
let content: String // Can be long
let date: Date
}
var config = DataTableConfiguration()
config.textLayout = .wrap
config.rowHeightMode = .automatic(estimated: 80)
config.maxColumnWidth = 300 // Prevent super-wide columns
let columns: [DataTableColumn<Note>] = [
.init("Title", \.title),
.init("Content", \.content),
.init("Date") { $0.date.formatted() }
]
let dataTable = SwiftDataTable(data: notes, columns: columns, options: config)