Column()

Usage

Source

Column(
    accessor=None,
    /,
    **kwargs,
)

Description

Build a column-definition dictionary for DataTable(columns=[...]). This helper is the quickest way to create readable column configs from Python without manually repeating {"accessor": ...} for every column.

Parameters

accessor: str | None = None

Description: Record key rendered by the column. This becomes the column identifier used by helpers such as table.update_columns(selector="salary", ...). Example: Column("salary").

title: str

Description: Header label shown above the column. If omitted, the frontend falls back to the accessor or its built-in title formatting. Example: title="Annual Salary".

presentation: str

Description: Built-in display mode used to format cell values. Expected inputs: 'text', 'number', 'currency', 'date', 'datetime', 'badge', 'link', 'code', 'json', 'progress'. Example: presentation="currency".

sortable: bool

Description: Enables sorting for the column. Example: sortable=True.

editable: bool

Description: Enables double-click editing for the column. Pair this with editor when you want a custom Dash input component. Example: editable=True.

editor: Any

Description: Dash component used as the in-place editor for editable cells. Example: editor=dmc.NumberInput(min=0, thousandSeparator=",").

render: Any

Description: Dash component or renderer payload used for custom cell content. Example: render=dmc.Text("View", c="blue").

filter: Any

Description: Dash component rendered in the column filter popover. Example: filter=dmc.TextInput(placeholder="Filter names").

textAlign: str

Description: Horizontal alignment for cell content. Expected inputs: values accepted by Mantine/DataTable such as 'left', 'center', 'right'. Example: textAlign="right".

width: int | float | str

Description: Column width. You can pass a numeric pixel value or a CSS width string. Example: width=140.

cellsStyle: dict

Description: Inline style mapping applied to body cells. Example: cellsStyle={"fontVariantNumeric": "tabular-nums"}.

titleStyle: dict

Description: Inline style mapping applied to the header cell. Example: titleStyle={"textTransform": "uppercase"}.

draggable: bool

Description: Allows the column to participate in column dragging. Example: draggable=True.

toggleable: bool

Description: Allows the column to be shown or hidden by column customization controls. Example: toggleable=True.

resizable: bool

Description: Allows the column width to be resized by the user. Example: resizable=True.

defaultToggle: bool
Description: Initial visibility state used when column toggling is enabled. Example: defaultToggle=False.

Returns

dict
A Dash-safe column configuration dictionary.

Notes

The helper does not validate every possible column key. It simply builds a plain dictionary, which makes it safe to use with existing Mantine DataTable column options and this package’s Dash-specific additions.

Examples

>>> Column("salary", title="Salary", presentation="currency", currency="USD")
{'accessor': 'salary', 'title': 'Salary', 'presentation': 'currency', 'currency': 'USD'}
>>> Column("status", presentation="badge", badgeColorAccessor="statusColor")
{'accessor': 'status', 'presentation': 'badge', 'badgeColorAccessor': 'statusColor'}