Skip to content


A data table widget.

  • Focusable
  • Container


The example below populates a table with CSV data.

TableApp  lane  swimmer               country        time    4     Joseph Schooling      Singapore      50.39   2     Michael Phelps        United States  51.14   5     Chad le Clos          South Africa   51.14   6     László Cseh           Hungary        51.14   3     Li Zhuhao             China          51.26   8     Mehdy Metella         France         51.58   7     Tom Shields           United States  51.73   1     Aleksandr Sadovnikov  Russia         51.84 

import csv
import io

from import App, ComposeResult
from textual.widgets import DataTable

CSV = """lane,swimmer,country,time
4,Joseph Schooling,Singapore,50.39
2,Michael Phelps,United States,51.14
5,Chad le Clos,South Africa,51.14
6,László Cseh,Hungary,51.14
3,Li Zhuhao,China,51.26
8,Mehdy Metella,France,51.58
7,Tom Shields,United States,51.73
1,Aleksandr Sadovnikov,Russia,51.84"""

class TableApp(App):
    def compose(self) -> ComposeResult:
        yield DataTable()

    def on_mount(self) -> None:
        table = self.query_one(DataTable)
        rows = csv.reader(io.StringIO(CSV))

if __name__ == "__main__":
    app = TableApp()

Reactive Attributes

Name Type Default Description
show_header bool True Show the table header
fixed_rows int 0 Number of fixed rows
fixed_columns int 0 Number of fixed columns
zebra_stripes bool False Display alternating colors on rows
header_height int 1 Height of header row
show_cursor bool True Show a cell cursor

See Also