widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.91k stars 144 forks source link

[Feature Request] New Table component #63

Open Ben-Epstein opened 1 year ago

Ben-Epstein commented 1 year ago

I think sl.Table would be great, especially if It could come from a pandas dataframe (or list of dictionaries etc).

Currently, I need to do this to get a decent centered table

html = (f"""
            <table class='center' height="50%" width="100%" align=center cellpadding ="25">
              <tr>
                <th><h2>Question</h2></th>
                <th><h2>Answer</h2></th>
              </tr>
              {get_table_rows()}
            </table>
            """
        )

and then a get_table_rows helper function thats like this

def get_table_rows() -> str:
    table_rows = ""
    for question in State.history.value:
        table_rows += f"<tr>\n\t<td>{question.q}</td>\n\t<td>{question.a}</td>\n</tr>"
    return table_rows

It would be awesome if I could have a simple styled centered table from an object sl.Table(my_data)

maartenbreddels commented 1 year ago

Do you think it makes sense to implement this using https://solara.dev/api/dataframe but giving some options to remove some of the 'chrome' (pagination, stripes)