Skip to content

Static Table ​

This component displays tabular data in a read-only format. Perfect for showing structured information like file listings, configuration data, or any structured content that doesn't require user interaction.

PropertyValue
InteractivityNon-required

Demo ​

A gif that shows the static table component in action

API ​

Basic Example ​

swift
// Simple table with string arrays
let noora = Noora()
noora.table(
    headers: ["Name", "Version", "Status"],
    rows: [
        ["React", "18.2.0", "Active"],
        ["Vue", "3.3.4", "Active"],
        ["Angular", "16.1.0", "Deprecated"]
    ]
)

Advanced Example with TableData ​

swift
// Advanced table with custom styling and column configuration
let columns = [
    TableColumn(title: "Package", width: .flexible(min: 10, max: 20), alignment: .left),
    TableColumn(title: "Version", width: .fixed(10), alignment: .center),
    TableColumn(title: "Status", width: .auto, alignment: .right)
]

let rows: [[TerminalText]] = [
    [
        TerminalText("React"),
        TerminalText("\(.primary("18.2.0"))"),
        TerminalText("\(.success("Active"))")
    ],
    [
        TerminalText("Vue"),
        TerminalText("\(.primary("3.3.4"))"),
        TerminalText("\(.success("Active"))")
    ],
    [
        TerminalText("Angular"),
        TerminalText("\(.muted("16.1.0"))"),
        TerminalText("\(.warning("Deprecated"))")
    ]
]

let tableData = TableData(columns: columns, rows: rows)
noora.table(tableData)

Semantic Styling Example ​

swift
// Table with semantic styling for better visual hierarchy
let headers: [TableCellStyle] = [
    .primary("Package"),
    .secondary("Version"),
    .accent("Status")
]

let rows: [StyledTableRow] = [
    [.plain("React"), .success("18.2.0"), .success("Active")],
    [.plain("Vue"), .success("3.3.4"), .success("Active")],
    [.plain("Angular"), .muted("16.1.0"), .warning("Deprecated")]
]

noora.table(headers: headers, rows: rows)

Options ​

Basic table method ​

AttributeDescriptionRequiredDefault value
headersArray of column header stringsYes
rowsArray of row data (each row is an array of strings)Yes
rendererA rendering interface that holds the UI stateNoRenderer()

Advanced table method with TableData ​

AttributeDescriptionRequiredDefault value
dataTableData object with custom columns and contentYes
rendererA rendering interface that holds the UI stateNoRenderer()

Semantic styling method ​

AttributeDescriptionRequiredDefault value
headersArray of column headers with semantic stylingYes
rowsArray of row data with semantic stylingYes
rendererA rendering interface that holds the UI stateNoRenderer()

TableColumn Options ​

PropertyDescriptionOptions
titleColumn header textTerminalText or String
widthColumn width behavior.auto, .fixed(Int), .flexible(min: Int, max: Int?)
alignmentText alignment.left, .center, .right

TableCellStyle Options ​

StyleDescription
.plain(String)Standard text without special styling
.primary(String)Primary theme color styling
.secondary(String)Secondary theme color styling
.success(String)Success/positive styling (typically green)
.warning(String)Warning styling (typically yellow/orange)
.danger(String)Error/danger styling (typically red)
.muted(String)Subdued/muted styling
.accent(String)Accent color styling

Released under the MIT License.