# Tables API Reference See Source See Output Name | Age | City ---|---|--- Alice | 25 | New York Bob | 30 | San Francisco Charlie | 35 | London Total | 90 [code] def ex_tables0(): return Table( Thead(Tr(Th('Name'), Th('Age'), Th('City'))), Tbody(Tr(Td('Alice'), Td('25'), Td('New York')), Tr(Td('Bob'), Td('30'), Td('San Francisco')), Tr(Td('Charlie'), Td('35'), Td('London'))), Tfoot(Tr(Td('Total'), Td('90')))) [/code] See Source See Output Name | Age | City ---|---|--- Alice | 25 | New York Bob | 30 | San Francisco Charlie | 35 | London Total | 90 [code] def ex_tables1(): header = ['Name', 'Age', 'City'] body = [['Alice', '25', 'New York'], ['Bob', '30', 'San Francisco'], ['Charlie', '35', 'London']] footer = ['Total', '90'] return TableFromLists(header, body, footer) [/code] See Source See Output NAME | AGE | CITY ---|---|--- Alice | 30 years | New York Bob | 25 years | London [code] def ex_tables2(): def body_render(k, v): match k.lower(): case 'name': return Td(v, cls='font-bold') case 'age': return Td(f"{v} years") case _: return Td(v) header_data = ['Name', 'Age', 'City'] body_data =[{'Name': 'Alice', 'Age': 30, 'City': 'New York'}, {'Name': 'Bob', 'Age': 25, 'City': 'London'}] return TableFromDicts(header_data, body_data, header_cell_render=lambda v: Th(v.upper()), body_cell_render=body_render) [/code] ### Table Source [code] Table(*c, cls=(, , , ), **kwargs) -> fastcore.xml.FT [/code] > Creates a table **Params** * `c` Components (typically `Thead`, `Tbody`, `Tfoot`) * `cls` Additional classes on the table * `kwargs` **Returns:** Table component ### TableFromLists Source [code] TableFromLists(header_data: Sequence, body_data: Sequence[Sequence], footer_data=None, header_cell_render=, body_cell_render=, footer_cell_render=, cls=(, , , ), sortable=False, **kwargs) -> fastcore.xml.FT [/code] > Creates a Table from a list of header data and a list of lists of body data **Params** * `header_data` List of header data * `body_data` List of lists of body data * `footer_data` List of footer data * `header_cell_render` Function(content) -> FT that renders header cells * `body_cell_render` Function(key, content) -> FT that renders body cells * `footer_cell_render` Function(key, content) -> FT that renders footer cells * `cls` Additional classes on the table * `sortable` Whether to use sortable table * `kwargs` **Returns:** Table from lists ### TableFromDicts Source [code] TableFromDicts(header_data: Sequence, body_data: Sequence[dict], footer_data=None, header_cell_render=, body_cell_render= at 0x752645f85b20>, footer_cell_render= at 0x752645f85bc0>, cls=(, , , ), sortable=False, **kwargs) -> fastcore.xml.FT [/code] > Creates a Table from a list of header data and a list of dicts of body data **Params** * `header_data` List of header data * `body_data` List of dicts of body data * `footer_data` List of footer data * `header_cell_render` Function(content) -> FT that renders header cells * `body_cell_render` Function(key, content) -> FT that renders body cells * `footer_cell_render` Function(key, content) -> FT that renders footer cells * `cls` Additional classes on the table * `sortable` Whether to use sortable table * `kwargs` **Returns:** Styled Table * * * ### TableT __ Option | Value | Option | Value | Option | Value ---|---|---|---|---|--- divider | uk-table-divider | striped | uk-table-striped | hover | uk-table-hover sm | uk-table-sm | lg | uk-table-lg | justify | uk-table-justify middle | uk-table-middle | responsive | uk-table-responsive | | ### Tbody Source [code] Tbody(*rows, cls=(), sortable=False, **kwargs) [/code] > **Params** * `rows` * `cls` * `sortable` * `kwargs` ### Th Source [code] Th(*c, cls=(), shrink=False, expand=False, small=False) [/code] > **Params** * `c` Components that go in the cell * `cls` Additional classes on the cell container * `shrink` Whether to shrink the cell * `expand` Whether to expand the cell * `small` Whether to use a small table **Returns:** Table cell ### Td Source [code] Td(*c, cls=(), shrink=False, expand=False, small=False) [/code] > **Params** * `c` Components that go in the cell * `cls` Additional classes on the cell container * `shrink` Whether to shrink the cell * `expand` Whether to expand the cell * `small` Whether to use a small table **Returns:** Table cell