Tables API Reference
Name | Age | City |
---|---|---|
Alice | 25 | New York |
Bob | 30 | San Francisco |
Charlie | 35 | London |
Total | 90 |
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'))))
Name | Age | City |
---|---|---|
Alice | 25 | New York |
Bob | 30 | San Francisco |
Charlie | 35 | London |
Total | 90 |
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)
NAME | AGE | CITY |
---|---|---|
Alice | 30 years | New York |
Bob | 25 years | London |
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)
Table
SourceTable(*c, cls=(<TableT.middle: 'uk-table-middle'>, <TableT.divider: 'uk-table-divider'>, <TableT.hover: 'uk-table-hover'>, <TableT.sm: 'uk-table-sm'>), **kwargs) -> fastcore.xml.FT
Creates a table
c
Components (typicallyThead
,Tbody
,Tfoot
)cls
Additional classes on the tablekwargs
Returns: Table component
TableFromLists
SourceTableFromLists(header_data: Sequence, body_data: Sequence[Sequence], footer_data=None, header_cell_render=<function Th at 0x7f31fe01d760>, body_cell_render=<function Td at 0x7f31fe01d6c0>, footer_cell_render=<function Td at 0x7f31fe01d6c0>, cls=(<TableT.middle: 'uk-table-middle'>, <TableT.divider: 'uk-table-divider'>, <TableT.hover: 'uk-table-hover'>, <TableT.sm: 'uk-table-sm'>), sortable=False, **kwargs) -> fastcore.xml.FT
Creates a Table from a list of header data and a list of lists of body data
header_data
List of header databody_data
List of lists of body datafooter_data
List of footer dataheader_cell_render
Function(content) -> FT that renders header cellsbody_cell_render
Function(key, content) -> FT that renders body cellsfooter_cell_render
Function(key, content) -> FT that renders footer cellscls
Additional classes on the tablesortable
Whether to use sortable tablekwargs
Returns: Table from lists
TableFromDicts
SourceTableFromDicts(header_data: Sequence, body_data: Sequence[dict], footer_data=None, header_cell_render=<function Th at 0x7f31fe01d760>, body_cell_render=<function <lambda> at 0x7f31fe01d8a0>, footer_cell_render=<function <lambda> at 0x7f31fe01d940>, cls=(<TableT.middle: 'uk-table-middle'>, <TableT.divider: 'uk-table-divider'>, <TableT.hover: 'uk-table-hover'>, <TableT.sm: 'uk-table-sm'>), sortable=False, **kwargs) -> fastcore.xml.FT
Creates a Table from a list of header data and a list of dicts of body data
header_data
List of header databody_data
List of dicts of body datafooter_data
List of footer dataheader_cell_render
Function(content) -> FT that renders header cellsbody_cell_render
Function(key, content) -> FT that renders body cellsfooter_cell_render
Function(key, content) -> FT that renders footer cellscls
Additional classes on the tablesortable
Whether to use sortable tablekwargs
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 |
Th
SourceTh(*c, cls=(), shrink=False, expand=False, small=False)
c
Components that go in the cellcls
Additional classes on the cell containershrink
Whether to shrink the cellexpand
Whether to expand the cellsmall
Whether to use a small table
Returns: Table cell
Td
SourceTd(*c, cls=(), shrink=False, expand=False, small=False)
c
Components that go in the cellcls
Additional classes on the cell containershrink
Whether to shrink the cellexpand
Whether to expand the cellsmall
Whether to use a small table
Returns: Table cell