Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Table

A sortable table of records with a single selectable row. Click a header to sort, click a row to select it; selected is a plain string trait, so it links to a map or chart with jslink.

Import

from manywidgets import Table

Example

API

TraitTypeDefaultDescription
rowsList—Records to display, one dict per row (JSON-safe values).
columnsList—Column specs: {key, label?, format?: text|number|bytes|datetime, align?: left|right, digits?}. Empty: derived from the first row.
id_keyUnicode''Row key used as the row id. Empty: the row index.
selectedUnicode''Id of the selected row (two-way; set by row click).
hoveredUnicode''Id of the row under the pointer, or empty.
max_heightUnicode'320px'CSS max-height of the scrolling body.
sortableBoolTrueAllow sorting by clicking a header.
titleUnicode''Optional table title.
empty_textUnicode'No rows'Shown when there are no rows.
widget_idUnicode''Stable unique id used for cross-widget linking (auto-assigned).

Rows are plain dicts; Table.from_records(records, columns, id_key) and Table.from_dataframe(df, id_key) build one from an iterable of dicts or a pandas DataFrame (values are coerced to JSON, so the state survives static export). When columns is empty they are derived from the first row; when id_key is empty the row index is the id. Formats: text (default), number (toLocaleString, optional digits), bytes (5.3 GB), datetime (ISO input → 2025-10-29 11:11:30, UTC).

Linking the selection

selected is two-way: a row click writes it, and writing it from outside highlights and scrolls to the row. Link it to another widget’s trait with jslink so the two stay in sync without a kernel:

from ipywidgets import jslink

jslink((table, "selected"), (geo_map, "selected"))