Data table -- composite widget built from columns, rows, and scrollable containers.
Props
columns(list of maps) -- column definitions. Each column is%{key: string, label: string}. Thekeymaps to row data fields. Optional per-column fields:align-- horizontal alignment for the column cells ("left","center","right"). Default:"left".width-- column width as aToddy.Iced.Lengthvalue. Default::fill.sortable-- whether clicking the header triggers a sort event. Default:false.
rows(list of maps) -- data rows. Each row is a map where keys correspond to columnkeyvalues.header(boolean) -- show header row. Default: true.separator(boolean) -- show separator line below header. Default: true.width(length) -- table width. Default: fill. SeeToddy.Iced.Length.padding(number | map) -- table padding. SeeToddy.Iced.Padding.sort_by(string | nil) -- key of the currently sorted column.sort_order(:asc|:desc| nil) -- current sort direction.header_text_size(number) -- header row text size in pixels.row_text_size(number) -- body row text size in pixels.cell_spacing(number) -- horizontal spacing between cells in pixels.row_spacing(number) -- vertical spacing between rows in pixels.separator_thickness(number) -- separator line thickness in pixels.separator_color(color) -- separator line color. SeeToddy.Iced.Color.a11y(map) -- accessibility overrides. SeeToddy.Iced.A11y.
Summary
Functions
Sets accessibility annotations.
Converts this table struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the horizontal spacing between cells in pixels.
Sets the column definitions.
Sets whether the header row is shown.
Sets the header text size in pixels.
Creates a new table struct with optional keyword opts.
Sets the table padding.
Sets the vertical spacing between rows in pixels.
Sets the row text size in pixels.
Sets the data rows.
Sets whether the separator line is shown.
Sets the separator line color.
Sets the separator line thickness in pixels.
Sets the currently sorted column key.
Sets the current sort direction.
Sets the table width.
Applies keyword options to an existing table struct.
Types
@type option() :: {:columns, [map()]} | {:rows, [map()]} | {:header, boolean()} | {:separator, boolean()} | {:width, Toddy.Iced.Length.t()} | {:padding, Toddy.Iced.Padding.t()} | {:sort_by, String.t()} | {:sort_order, sort_order()} | {:header_text_size, number()} | {:row_text_size, number()} | {:cell_spacing, number()} | {:row_spacing, number()} | {:separator_thickness, number()} | {:separator_color, Toddy.Iced.Color.input()} | {:a11y, Toddy.Iced.A11y.t()}
@type sort_order() :: :desc | :asc
@type t() :: %Toddy.Iced.Widget.Table{ a11y: Toddy.Iced.A11y.t() | nil, cell_spacing: number() | nil, columns: [map()] | nil, header: boolean() | nil, header_text_size: number() | nil, id: String.t(), padding: Toddy.Iced.Padding.t() | nil, row_spacing: number() | nil, row_text_size: number() | nil, rows: [map()] | nil, separator: boolean() | nil, separator_color: Toddy.Iced.Color.t() | nil, separator_thickness: number() | nil, sort_by: String.t() | nil, sort_order: sort_order() | nil, width: Toddy.Iced.Length.t() | nil }
Functions
@spec a11y(table :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
Sets accessibility annotations.
@spec build(table :: t()) :: Toddy.Iced.ui_node()
Converts this table struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the horizontal spacing between cells in pixels.
Sets the column definitions.
Sets whether the header row is shown.
Sets the header text size in pixels.
Creates a new table struct with optional keyword opts.
@spec padding(table :: t(), padding :: Toddy.Iced.Padding.t()) :: t()
Sets the table padding.
Sets the vertical spacing between rows in pixels.
Sets the row text size in pixels.
Sets the data rows.
Sets whether the separator line is shown.
@spec separator_color(table :: t(), separator_color :: Toddy.Iced.Color.input()) :: t()
Sets the separator line color.
Sets the separator line thickness in pixels.
Sets the currently sorted column key.
@spec sort_order(table :: t(), sort_order :: sort_order()) :: t()
Sets the current sort direction.
@spec width(table :: t(), width :: Toddy.Iced.Length.t()) :: t()
Sets the table width.
Applies keyword options to an existing table struct.