Search code examples
pythonnicegui

NiceGui: Hide table header


Following the documentation example.

I wasn't able to figure out how to remove the table headers <th>, in this case the "Name" and "Age" row.

columns = [
    {'name': 'name', 'label': 'Name', 'field': 'name', 'required': True, 'align': 'left'},
    {'name': 'age', 'label': 'Age', 'field': 'age', 'sortable': True},
]
rows = [
    {'name': 'Alice', 'age': 18},
    {'name': 'Bob', 'age': 21},
    {'name': 'Carol'},
]
ui.table(columns=columns, rows=rows, row_key='name')

ui.run()

Solution

  • You can add a "hidden" class to the table header like this:

    ui.table(columns=columns, rows=rows, row_key='name').props('table-header-class=hidden')